For those times when you need to check for a null and return a string if it is null there's the null coalescing operator ??
string myStr = "The variable is:" + (x ?? "null");
Null coalescing operator ? in C#
Whether you're a seasoned veteran or a struggling beginner, Web Radiance is the web development and web design forum for you. You'll find answers to all your HTML, CSS, SEO, and Programming needs. Pull up a chair and stay awhile.
Page 1 of 1
Null coalescing operator ? in C#
#2
Posted 02 September 2006 - 05:47 PM
oo, I'll have to remember that 
I've only been learning c# for a few weeks (I didn't like VB, and C#'s 'VB-feel' put me off), but I can see this will cut out a lot of pointless

EDIT: Bah, need to use code tags for my indentation to show v_v
EDIT2: As a veteran C++ coder, I can't help reading a simple if-else in C# without wanting to stick a load of curly braces in ^.^
EDIT3:

EDIT4: I know I should have used 'count', or 'ptr', but I was keeping inline with the C# example >8(
EDIT5: Ok, no more coffee for me....
I've only been learning c# for a few weeks (I didn't like VB, and C#'s 'VB-feel' put me off), but I can see this will cut out a lot of pointless
if (myVariable == null) do stuff; else do otherStuff;
EDIT: Bah, need to use code tags for my indentation to show v_v
EDIT2: As a veteran C++ coder, I can't help reading a simple if-else in C# without wanting to stick a load of curly braces in ^.^
EDIT3:
if (myVariable == 0) {
do stuff;
}
else {
do otherStuff;
}
EDIT4: I know I should have used 'count', or 'ptr', but I was keeping inline with the C# example >8(
EDIT5: Ok, no more coffee for me....
This post has been edited by ShakingSpirit: 02 September 2006 - 05:53 PM
QUOTE(MSN)
Benbramz says: i had orgasmic thoughts at the excitement of that
Share this topic:
Page 1 of 1


Help
This topic is locked

MultiQuote









