Re: String empty test
From: William Stacey [MVP] (staceywREMOVE_at_mvps.org)
Date: 03/25/04
- Next message: PocketNerd: "Re: Minimise Button"
- Previous message: Andreas Håkansson: "Re: String empty test"
- In reply to: Andreas Håkansson: "Re: String empty test"
- Next in thread: Willy Denoyette [MVP]: "Re: String empty test"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 25 Mar 2004 16:29:15 -0500
yes. I think the IL would turn out to be the same. You could also create a
static method in your helper library and kill all the birds like:
public static bool IsNullOrEmptyTrim(string str)
{
return ( str == null || str.Trim() == string.Empty );
}
Cheers!
--
William Stacey, MVP
"Andreas Håkansson" <andy.h (at) telia.com> wrote in message
news:evdGt5qEEHA.576@TK2MSFTNGP11.phx.gbl...
> William,
>
> Or even shorter
>
> public bool IsNullOrEmpty(string str)
> {
> return ( str == null || str == string.Empty )
> }
>
> //Andreas
>
> "William Stacey [MVP]" <staceywREMOVE@mvps.org> skrev i meddelandet
> news:eHUoq4qEEHA.1228@TK2MSFTNGP11.phx.gbl...
> > 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
> > news:OpIQl1qEEHA.3412@TK2MSFTNGP10.phx.gbl...
> > > 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" <mattias.dont.want.spam@mvps.org> skrev i
meddelandet
> > > news:%234tL1xqEEHA.3748@TK2MSFTNGP11.phx.gbl...
> > > >
> > > > >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
> > > >
> > > > --
> > > > Mattias Sjögren [MVP] mattias @ mvps.org
> > > > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> > > > Please reply only to the newsgroup.
> > >
> > >
> >
>
>
- Next message: PocketNerd: "Re: Minimise Button"
- Previous message: Andreas Håkansson: "Re: String empty test"
- In reply to: Andreas Håkansson: "Re: String empty test"
- Next in thread: Willy Denoyette [MVP]: "Re: String empty test"
- Messages sorted by: [ date ] [ thread ]