T
Trev
Hi,
I have a series of functions which do the following:
ValidateData( args ); //args if of type ArrayList
// Work out if the data is valid or not, and work out the type of
args[1] - int, string, whatever?
if((bool)args[0]) // valid data
{
WriteDataToDB( args[1] );
}
However, it fails, as arg[1] is of type object, and I need to cast it
to type int, string whatever.
Rather than do a big switch statement, testing the type of args[1], is
there a way of
simply casting it using a function like:
ValidateData( args, ref type TypeOfArg1 ); //args if of type ArrayList
// Work out if the data is valid or not, and work out the type of
args[1] - int, string, whatever?
// work out type of args[1]
if((bool)args[0]) // valid data
{
WriteDataToDB( (TypeOfArg1)args[1] );
}
TIA
Trev
I have a series of functions which do the following:
ValidateData( args ); //args if of type ArrayList
// Work out if the data is valid or not, and work out the type of
args[1] - int, string, whatever?
if((bool)args[0]) // valid data
{
WriteDataToDB( args[1] );
}
However, it fails, as arg[1] is of type object, and I need to cast it
to type int, string whatever.
Rather than do a big switch statement, testing the type of args[1], is
there a way of
simply casting it using a function like:
ValidateData( args, ref type TypeOfArg1 ); //args if of type ArrayList
// Work out if the data is valid or not, and work out the type of
args[1] - int, string, whatever?
// work out type of args[1]
if((bool)args[0]) // valid data
{
WriteDataToDB( (TypeOfArg1)args[1] );
}
TIA
Trev