Structures
เบญญาภา รัตนวิชัย 650710218
Structures คืออะไร
struct Student_ID_card{
public int id;
public String name;
public String faculty;
public String major;
public int year;
}using System;
struct Student_ID_card{
public int id;
public String name;
public String faculty;
public String major;
public int year;
}
class Student {
static void Main(string[] args){
Student_ID_card student1;
student1.id = 1234567;
student1.name = "Benyapha";
student1.faculty = "Science";
student1.major = "Computer Science";
student1.year = 3;
Console.WriteLine("ID: " + student1.id);
Console.WriteLine("Name: " + student1.name);
Console.WriteLine("Faculty: " + student1.faculty);
Console.WriteLine("Major: " + student1.major);
Console.WriteLine("Year: " + student1.year);
}
}ผลลัพธ์
แล้วถ้าเราต้องการสร้าง student2 ล่ะ ทำได้ดังนี้
เท่ากับว่าข้อมูลนักศึกษา 2 คน มีบัตรนักศึกษา 2 ใบแล้ว
ผลลัพธ์
เปรียบเทียบกับภาษา Java, C, Python
คลิปนำเสนอ
Presentation (Slides)
แหล่งที่มาอ้างอิง
แหล่งที่มาอ้างอิงเนื้อหา
Last updated
