Showing posts with label different. Show all posts
Showing posts with label different. Show all posts

Monday, June 17, 2013

[C#] ความแตกต่างระหว่างเมธอดที่ใช้ new กับ override
[C#] What Different between new and override Method

override - เมธอดของคลาสแม่ถูกเขียนทับในคลาสลูก
override - a method of a base class is overridden in a derived class

new - เมธอดของคลาสแม่ถูกซ่อนเอาไว้จากคลาสลูก โดยการประกาศเมธอดที่เหมือนกับคลาสแม่ในคลาสลูก
new - a method of a base class is hidden in a derived class by defining the same method of a base class in a derived class

ถ้าไม่ได้กำหนดคีย์เวิร์ดว่าเป็น override หรือ new ค่าตั้งต้นจะเป็น new
If you do not specify either override or new keyword, the default keyword is new