D
Doesn't Work At McDonalds
intval() in PHP is a simple function... you toss it a string and it
gives you the integer value. If the string is all text, the value is
0. It's very nice for simple form validation where you want to force
a form value to be an integer. If the user enters one, it gets used.
If they mess around, the value becomes 0. Simple.
So, after googling for how to do this in C# with asp.net, the best I
can come up with is Convert.ToInt32() which tosses an error if the
string you feed it isn't an integer. I don't want an error. I want a
zero.
Is there a function built into C#/asp.net that's like intval()?
gives you the integer value. If the string is all text, the value is
0. It's very nice for simple form validation where you want to force
a form value to be an integer. If the user enters one, it gets used.
If they mess around, the value becomes 0. Simple.
So, after googling for how to do this in C# with asp.net, the best I
can come up with is Convert.ToInt32() which tosses an error if the
string you feed it isn't an integer. I don't want an error. I want a
zero.
Is there a function built into C#/asp.net that's like intval()?