Welcome to WebmasterWorld Guest from 23.22.46.195

Forum Moderators: ocean10000

C# syntax question

   
4:57 am on Jul 25, 2007 (gmt 0)

10+ Year Member



hi,

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.

Thanks
-BT

[edited by: BlackTulip at 4:58 am (utc) on July 25, 2007]

6:03 am on Jul 25, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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#?

3:29 am on Jul 26, 2007 (gmt 0)

10+ Year Member



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]

6:06 am on Jul 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.

:)

8:39 pm on Jul 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This would be the Ternary Operator.
8:43 pm on Jul 26, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> 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 :)

12:46 am on Jul 27, 2007 (gmt 0)

10+ Year Member



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...]

1:06 pm on Jul 27, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month