Array Structure Array List Enumeration Stack Queue C

  • Slides: 26
Download presentation

รปแบบของโครงสรางขอมลของ Array Structure Array. List Enumeration Stack Queue C#

รปแบบของโครงสรางขอมลของ Array Structure Array. List Enumeration Stack Queue C#

การประกาศอารเรย ตวอยาง string[] My. Array = new string[3]; My. Array[0] = “TUK”; My. Array[1]

การประกาศอารเรย ตวอยาง string[] My. Array = new string[3]; My. Array[0] = “TUK”; My. Array[1] = “TIM”; My. Array[2] = “TIP”; My. Array[3] = “TON”; ตวอยาง int[] Your. Array; Your. Array = new int[7]; Your. Array[0] = 10; Your. Array[1] = 20;

ลำดบทในอารเรย int[] sc; sc = new int[5]{12, 3, 43, 27, 56}; 12 7 3

ลำดบทในอารเรย int[] sc; sc = new int[5]{12, 3, 43, 27, 56}; 12 7 3 43 27 56

การกำหนด Struct "struct" keyword ���� struct Student. Info { public int id; public string

การกำหนด 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.

การกำหนด 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;

การสราง 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

การเรยกใช 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

อารเรยของ 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