Variable type question

A

Andrea Williams

Is there a way to change the datatype of a return variable inside a
function?

Example:
public static ?XXX? RequestVar(string strValue)
{
return Request.Form[strValue)];
}

The value may be a string, int, long or could even be a boolean.

Thanks,
Andrea
 
K

Kevin Spencer

Values in the Request.Form Collection are always strings. Your obvious bet
would be to return a string. There is no way that the function or anything
else can guess what data type a string is supposed to represent. However,
the calling function, as it is passing the string representing the form
field that is desired, should know the data type it is looking for, and the
conversion can be made from the calling function.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top