How to use class with public data members in C#

1 Answer

0 votes
using System;

class Point {
    public int x;
    public int y;
}

class Program
{
    static void Main()
    {
        var p = new Point();
        
        p.x = 7;
        p.y = 10;
        
        Console.WriteLine($"x = {p.x}, y = {p.y}");
    }
}



/*
run

x = 7, y = 10

*/

 



answered Nov 27, 2020 by avibootz

Related questions

1 answer 296 views
1 answer 255 views
1 answer 251 views
1 answer 287 views
1 answer 252 views
252 views asked Jan 1, 2017 by avibootz
1 answer 337 views
...