0

Constructores C#

If this structure: public struct Point{ public int x; public int y; public Point(int a, int b){ this.x=a; this.y=b; } } So... is that a Constructor? And is correct use it with (new) for struct type initialization: Point p= new Point(1,5); Can I iniatilizating a struct var more efficiently? Things...

27th Apr 2020, 10:39 AM
Raul Saez
Raul Saez - avatar
2 Answers
0
Yes that’s a constructor. It has the same name as the class/struct and it doesn’t have a return type. Initialization looks fine.
27th Apr 2020, 4:42 PM
Chris Persichetti
Chris Persichetti - avatar
0
ok, thinks.. I finish my C# trining and struct was at the end... jaja I was jumping...
27th Apr 2020, 5:42 PM
Raul Saez
Raul Saez - avatar