Welcome to WebmasterWorld Guest from 220.127.116.11 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Become a Pro Member
C# syntax question BlackTulip
I remember i saw somewhere a quick and dirty c# syntax, like:
(Variable(or expression i dont remeber), 1)
if it is evaluated null returns 1. has anybody bumped into this?
it has been stuck in my head all day; like a friend's name u try to remember.
edited by: BlackTulip at 4:58 am (utc) on July 25, 2007]
I'm still in the very early learning stages of C# and your question is a little confusing to me. Are you referring to the equivalent of something like the conditional IIf in Visual Basic? Is so I think the proper syntax in C# is:
o = (cond1 = cond2? truevalue : falsevalue);
If I'm wrong I'm sorry. And hopefully I'll learn something in the process. Are you having an easy time learning C#?
Thank you GaryK, I think thats the one i was trying to recall. you saved my brain from a nagging loop!
I love c#, everything aside I find it quite elegant.
PS: so is this kinda IF imported from VB?
edited by: BlackTulip at 3:30 am (utc) on July 26, 2007] GaryK
I'm fluent in many computer languages so learning C# is just a matter of learning the right syntax for stuff, and finding the time to dedicate to learning without being interrupted.
Most languages that I've used have the equivalent of that conditional statement. VBScript being the notable exception.
This would be the Ternary Operator. Lord Majestic
> PS: so is this kinda IF imported from VB?
That short style IF syntax taken from original K&Rs C - I find C# so much better :)
cool now I know its called a Ternary operation.
this reminds me of my renewed interest to re-study Math, god know how many credits of Math I have forgotten.
...] en.wikipedia.org Easy_Coder
That's ironic BlackTulip... I'm refreshing on Statistics right now. That stuff is 20 years behind me and your right, you do forget it.