การกำหนด Struct "struct" keyword ���� struct Student. Info { public int id; public string name; public string dept; } ����� ��� struct ��������� "public” 16
การกำหนด Struct ในสวนโปรแกรมใหประกาศ นอกเมธอด Struct ไวภายในคลาส using System; class Struct. Test { struct Std. Info { public int id; public string name; public string dept; } public static void Main() { : } } 17
การสราง Struct Syntax: <struct-name> <var-name> = new struct-name(); หรอ <struct-name> <var-name>; Examples: using System; class Struct. Test { struct Std. Info { public int id; public string name; public string dept; } public static void Main() { Std. Info student = new Std. Info(); : } } using System; class Struct. Test { struct Std. Info { public int id; public string name; public string dept; } public static void Main() { Std. Info student; : } } 18
การเรยกใช Struct Variable Syntax: <var-name>. <member-name> Example: using System; class Struct. Test { struct Std. Info { public int id; public string name; public string dept; } public static void Main() { Std. Info student; student. id = 48541234; student. name = "Nicole"; student. dept = "IE"; Console. Write. Line("ID: {0}", student. id); } } 19
อารเรยของ Structs Array of integers 7 3 10 5 8 17 7 0 1 2 3 4 5 6 7 8 9 10 10 11 Struct of student info ID: Name: Dept: 3 5010000 Aum CPE Array of structs of student info ID: Name: Dept: 5010000 Aum CPE 0 ID: Name: Dept: 5020000 Nat IE 1 ID: Name: Dept: 20 5010000 Top EE 2