25 April 2013

Use Ternary Operator in Business Layer in C#.Net

      Today we will discuss about the Ternary Operator in Business Layer in C#.Net.
Example for Ternary Operator :
Create a One Class for Business Layer called BLEmp.cs
Copy and paste in the BLEmp.cs File

Private static string _EmpName;
        public static string EmpName
{
get { return _EmpName == string.Empty ? "please Enter Name" : _EmpName; }
set
{ _EmpName = value; }
}
 
Drag and Drop TextBox and Button on the form.
Copy and Paste this code in the Button Click Event
 
BLEmp.EmpName = textBox1.Text;
MessageBox.Show(BLEmp.EmpName);

No comments: