Monday, March 26, 2012

What is the alternative ?

What is the alternative ?

try
{
id = Int32.Parse(Request.QueryString["rid"]);
}
catch
{
id = 0;
}

I'm using .NET 1.x

Not sure if this is what you are looking for.

bool mRIDParse;
int mRID;
string mRIDQuery = Request.QueryString["rid"];

mRIDParse = int.TryParse(mRIDQuery, out mRID);

if (mRIDParse) { }

HTH,
Ryan


TryParse is a 2.0 method... won't help him in 1.1-land


MorningZ:

TryParse is a 2.0 method... won't help him in 1.1-land

Woops. Missed that part. I guess the best thing is to get the value of the query string using a string and check that's it's not equal to null or an empty string and then use int.Parse.

HTH,
Ryan

0 comments:

Post a Comment