There was an error while loading. Please reload this page.
#Constructors constructor เป็นเมธอดในคลาส ที่มีชื่อเดียวกับคลาสและไม่มีชนิดการส่งกลับ จะถูกเรียกใช้งานทันทีที่มีการสร้างวัตถุจากคลาสนั้น constructor มีสถานะเป็นเมธอด จึงสามารถใช้งานในลักษณะต่างๆ ได้เช่นเดียวกับเมธอดทั่วไป สามารถใช้ modifier ต่างๆ ได้ สามารถทำ overloading ได้ ##Modifiers สําหรับ Constructors
##การทำ oveloading ของ Constructors
using System; public class Wine { public decimal Price; public int Year; public Wine (decimal price) { Price = price; } public Wine (decimal price, int year) : this(price) { Year = year; } }
##Nonpublic constructors