Ternary Operator (or) conditional operator In C#

In c# language, ternary operator (?) use to check a conduction, so other name of ternary operator is conditional operator, which work as a if statement. This operator compares two values. It produces a third value that depends on the result of the comparison. At compile-time, the C# compiler translates the ternary expression into branch statements such as brtrue.

public string check(string name, int pass) //Create function

        {
            //Use ternary operator ?

            //condition true then reply “Welcome Arvind”

            //condition falls then reply “Invalid Login or Password”

            return name == “arvind” && pass==123 ? “Welcome Arvind” : “Invalid Login or Password”;            

        }

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s