How to initialize the c# struct ( Identify the correct syntax )?
public struct Student
public String name;
public int age;
public int sid;
Create a parameterized constructor in Struct and assign data to struct variables .
Student oStudent=new Student();
All of the above.
A structure object can be created using new in the same way as a class object, but it is not required. When new is used, the specified constructor is called. When new is not used, the object is still created, but it is not initialized. Thus, you will need to perform any initialization manually and by using Object initializer(as like option 3) we can define struct.
Back To Top