Welcome to WebmasterWorld Guest from 54.196.214.35

Forum Moderators: ocean10000

Message Too Old, No Replies

C# syntax question

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

Junior Member

10+ Year Member

joined:Apr 4, 2005
posts:43
votes: 0


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 July 25, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


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 July 26, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 4, 2005
posts:43
votes: 0


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 July 26, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 17, 2002
posts:2251
votes: 0


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 July 26, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2003
posts:1184
votes: 0


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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Aug 8, 2004
posts:1679
votes: 0


> 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 July 27, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Apr 4, 2005
posts:43
votes: 0


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 July 27, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 2, 2003
posts:1184
votes: 0


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.