คำตอบที่ได้รับเลือกจากเจ้าของกระทู้
ความคิดเห็นที่ 1
1. IEnumerator {} // IEnumerator มันคืออะไร
- คือ collection interface สำหรับเราใช้กับ linq กับ foreach ลูป
ตัวอย่าง IEnumerator<DataRow> drs = dataTable.AsEnumerator().Cast<DataRow> ();
foreach(DataRow dr in drs) { }
2.[XXX] //ไอตัวนี้คืออะไร ทำไมต้องประกาศเหนือฟังก์ชั่น
public void Get(float number)
{}
- คือ method attribute เหมือนเอาไว้บอก compiler ถึงคุณสมบัติของ method นี้
3. if(++count >= maxCount) // ++ ก่อน มันทำงานอย่างไรครับ คล้ายๆ for ไหม
- if(++count >= maxCount) ==> count = count + 1; if(count >= maxCount);
if(count++ >= maxCount) ==> if(count >= maxCount); count = count + 1;
4.
public GameObject impactPrefab;
GameObject[] impacts;
impacts = (GameObject)Instantiate(impactPrefab); // ทำไมออบเจ็ต ต้องไปอยู่ในวงเล็บ ()XXX() มันคืออะไรครับ
- direct cast type คือแปลง Instantiate(impactPrefab) ให้เป็น type GameObject
ตัวอย่างเช่น object a = "pantip"; string b = (string)a;
5. GetComponent<PhotonView> ().RPC ("GetShot", PhotonTargets.All, damage) // <XXX>.XX() มันคืออะไรครับ
- GetComponent<T> () = generic methods หา google เพิ่มเติมเองเกี่ยวกับการสร้าง generic methods
<PhotonView> = <T> generic type
.RPC ("GetShot", PhotonTargets.All, damage) = method ของ object GetComponent<PhotonView> ()
- คือ collection interface สำหรับเราใช้กับ linq กับ foreach ลูป
ตัวอย่าง IEnumerator<DataRow> drs = dataTable.AsEnumerator().Cast<DataRow> ();
foreach(DataRow dr in drs) { }
2.[XXX] //ไอตัวนี้คืออะไร ทำไมต้องประกาศเหนือฟังก์ชั่น
public void Get(float number)
{}
- คือ method attribute เหมือนเอาไว้บอก compiler ถึงคุณสมบัติของ method นี้
3. if(++count >= maxCount) // ++ ก่อน มันทำงานอย่างไรครับ คล้ายๆ for ไหม
- if(++count >= maxCount) ==> count = count + 1; if(count >= maxCount);
if(count++ >= maxCount) ==> if(count >= maxCount); count = count + 1;
4.
public GameObject impactPrefab;
GameObject[] impacts;
impacts = (GameObject)Instantiate(impactPrefab); // ทำไมออบเจ็ต ต้องไปอยู่ในวงเล็บ ()XXX() มันคืออะไรครับ
- direct cast type คือแปลง Instantiate(impactPrefab) ให้เป็น type GameObject
ตัวอย่างเช่น object a = "pantip"; string b = (string)a;
5. GetComponent<PhotonView> ().RPC ("GetShot", PhotonTargets.All, damage) // <XXX>.XX() มันคืออะไรครับ
- GetComponent<T> () = generic methods หา google เพิ่มเติมเองเกี่ยวกับการสร้าง generic methods
<PhotonView> = <T> generic type
.RPC ("GetShot", PhotonTargets.All, damage) = method ของ object GetComponent<PhotonView> ()
แสดงความคิดเห็น
มีคำถามเกี่ยวกับ ภาษา C# ครับ
2.[XXX] //ไอตัวนี้คืออะไร ทำไมต้องประกาศเหนือฟังก์ชั่น
public void Get(float number)
{}
3. if(++count >= maxCount) // ++ ก่อน มันทำงานอย่างไรครับ คล้ายๆ for ไหม
4.
public GameObject impactPrefab;
GameObject[] impacts;
impacts = (GameObject)Instantiate(impactPrefab); // ทำไมออบเจ็ต ต้องไปอยู่ในวงเล็บ ()XXX() มันคืออะไรครับ
5. GetComponent<PhotonView> ().RPC ("GetShot", PhotonTargets.All, damage) // <XXX>.XX() มันคืออะไรครับ
ทั้งหมดมาจากตัวอย่างโค้ดในเว็บนี้ครับ
[Spoil] คลิกเพื่อดูข้อความที่ซ่อนไว้
ผมอ่อนภาษา C# มาก แต่อยากเขียนโปรแกรมใน Unity เป็น
ขอบคุณครับ