Monday, March 3, 2008

Structs of C#

_____________________________________________

Structs of C#.

_____________________________________________

struct StudentRecord {
public string name;
public float gpa;

public StudentRecord(string name, float gpa) {
this.name = name;
this.gpa = gpa;
}
}

StudentRecord stu = new StudentRecord("Bob", 3.5f);
StudentRecord stu2 = stu;

stu2.name = "Sue";
Console.WriteLine(stu.name); // Prints Bob
Console.WriteLine(stu2.name); // Prints Sue

____________________________________________________________________

Note:Applicable for .net also asp.net.
____________________________________________________________________

No comments: