Jump to content

Is this a type of "if" statement?


K_Drive

Recommended Posts

I am going through a book on C# and ASP.Net.I ran across a statement that I don't quite understand.The book does not explain it.From the context I am assuming that it is an "if" statement. Here it is:

shippingRegion = (profile.ShippingRegion == null || profile.ShippingRegion == "" ? "1" : profile.ShippingRegion);

Here is the code around it:

		ProfileCommon profile = HttpContext.Current.Profile as ProfileCommon;		address1 = profile.Address1;		address2 = profile.Address2;		city = profile.City;		region = profile.Region;		postalCode = profile.PostalCode;		country = profile.Country;>		shippingRegion = (profile.ShippingRegion == null || profile.ShippingRegion == "" ? "1" : profile.ShippingRegion);		dayPhone = profile.DayPhone;		evePhone = profile.EvePhone;		mobPhone = profile.MobPhone;		email = Membership.GetUser(profile.UserName).Email;

If I need to add more explanation or code, please let me know. Thanks. K

Link to comment
Share on other sites

I'd rather call it the conditional operator. Because in the unlikely case that another ternary operator shows up, the term "ternary operator" will become ambiguous.

Link to comment
Share on other sites

Hmm... it actually seems the MSDN page agrees with you Ingolme... I used the other term anyway not only because of PHP, but also because that's the term I used on the MSDN search to find that page.Personally, I'm not sure that "ambiguity in the context of other operators" should ever really an issue in naming an operator. Bitwise operators, if mixed with arithmetic operators can become ambiguous when a programmer tries to interpret them. Arithmetic operators alone can sometimes do that.But that's purely a philosophical issue (with no practical impact), so we can agree to disagree.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...