C# 6.0 Yenilikleri – Parameters on classes and structs

Parameters on classes and structs : Classlar oluşturulurken constructer olmadan parametre alması sağlanmıştır.

public class RealCustomer(string firstName, string lastName) 
{ 
   public string FirstName { get; } = firstName;
   public string LastName { get; } = lastName; 
}

RealCustomer relCustomer = new RealCustomer("Yakup", "KALEBAŞI");
WriteLine(relCustomer.FirstName + " " + relCustomer.LastName);

 

Bunlar da hoşunuza gidebilir...