可使用Lambada運算式定義成員方法。
public class Program
{
public static void Main(string[] args)
{
Student person = new Student();
person.FirstName = "John";
person.LastName = "Lin";
Console.WriteLine(person.FullName);
}
}
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName => $"{FirstName} {LastName}";
}
沒有留言:
張貼留言