.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Use Ternary Operator in Business Layer in C#.Net

Posted By:Narayanan       Posted Date: April 12, 2013    Points: 40    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

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; }
            { _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;

if TextBox is empty "Please Enter Name" message will show other wise textBox value will show.


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend