Re: validate that string input is a negative number
- From: "mpetrotta@xxxxxxxxx" <mpetrotta@xxxxxxxxx>
- Date: 28 Mar 2007 09:20:37 -0700
On Mar 28, 7:47 am, "Mythran" <kip_pot...@xxxxxxxxxxx> wrote:
"Alberto Poblacion" <earthling-quitaestoparacontes...@xxxxxxxxxxxxx> wrote
in messagenews:uAO52jUcHHA.4888@xxxxxxxxxxxxxxxxxxxxxxx
"Larry Lard" <larryl...@xxxxxxxxxxxxxx> wrote in message
news:56vca3F29fvh4U1@xxxxxxxxxxxxxxxxxxxxx
- Use a regular expression such as "-\d+".
Also, that regular expression would pass "-0", which isn't negative.
Okay, let's refine it a little:
@"^-[1-9]\d*$"
lol sorry, have too:
-01 wouldn't pass the above expression pattern...
@"^-\d*[1-9]\d*$" should...haven't tested though...
Or just a nice simple
int val;
return Int32.TryParse(s, out val) && val < 0
Michael
.
- Follow-Ups:
- Re: validate that string input is a negative number
- From: Jon Skeet [C# MVP]
- Re: validate that string input is a negative number
- References:
- Re: validate that string input is a negative number
- From: Alberto Poblacion
- Re: validate that string input is a negative number
- From: Larry Lard
- Re: validate that string input is a negative number
- From: Alberto Poblacion
- Re: validate that string input is a negative number
- From: Mythran
- Re: validate that string input is a negative number
- Prev by Date: Re: downloading a single file using multiple threads
- Next by Date: Re: How to get attribute type from Active Directory
- Previous by thread: Re: validate that string input is a negative number
- Next by thread: Re: validate that string input is a negative number
- Index(es):