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 179 views
1 answer 164 views
1 answer 145 views
1 answer 168 views
1 answer 155 views
155 views asked Jan 1, 2017 by avibootz
1 answer 227 views
...