Willy,
I've never actually went down the IL road (I really should), do you
mean
shortest as in "you wont have to create an class instance" or shorter as
in
"the shortest possible IL" ?
//Andreas
"Willy Denoyette [MVP]" <
[email protected]> skrev i meddelandet
Or the shortest?
public static bool MyNullOrEmpty(string value)
{
return ((value == null) || (value.length== 0));
}
Willy.
"Andreas Håkansson" <andy.h (at) telia.com> wrote in message
William,
Or even shorter
public bool IsNullOrEmpty(string str)
{
return ( str == null || str == string.Empty )
}
//Andreas
"William Stacey [MVP]" <
[email protected]> skrev i meddelandet
It would probably look something like this:
public bool IsNullOrEmpty(string str)
{
if ( str == null || str == string.Empty )
return true;
return false;
}
--
William Stacey, MVP
"Andreas Håkansson" <andy.h (at) telia.com> wrote in message
Mattias,
Other then helping to shorten and simply code, do you know if
there
are any (i guess not) performance advantages (i.e will it compile
into
shorter IL), or other nice features with it ?
//Andreas
"Mattias Sjögren" <
[email protected]> skrev i
meddelandet
or is there another way to perform the null and
empty test at the same time?
In Whidbey they're adding a new static method on the String class
for
this, called IsNullOrEmpty. So you'll be able to write
if ( !String.IsNullOrEmpty( str ) )
Mattias