1- String Interpolation
public string FullName => $"{FirstName}
{LastName}";
2- Expression bodied function
private Employee GetData(int Id)
=> Id != 0
? new Employee
{
EmpId = 1,
EmpName = "Suraj"
}
: null;
public class Employee
{
public int EmpId { get; set; }
public string EmpName
{ get; set; }
}
3- Null-conditional operators
var EmpId = emp?.EmpId;
var EmpName = emp?.EmpName ?? "Unspecified";
0 comments:
Post a Comment