J
Jim Heavey
I am trying to figure out how to write a generic "format" routine to return
a string type variable. I want to pass this routine an object and based on
the type of the object format according to the type. I tried something
like this, but of course it does not like this... How can I accomplish
this?
Here is a snipit of code...
private string ConvertType(object item )
{
string val;
switch (item.GetType())
{
case System.Int32:
val = item.ToString();
break;
case System.Guid:
val = item.ToString();
break;
case System.Single:
FormatTheNumber((single)item)
break;
case System.Double:
FormatTheNumber((Double)item)
break;
}
}
Thanks in advance for your assistance!!!
a string type variable. I want to pass this routine an object and based on
the type of the object format according to the type. I tried something
like this, but of course it does not like this... How can I accomplish
this?
Here is a snipit of code...
private string ConvertType(object item )
{
string val;
switch (item.GetType())
{
case System.Int32:
val = item.ToString();
break;
case System.Guid:
val = item.ToString();
break;
case System.Single:
FormatTheNumber((single)item)
break;
case System.Double:
FormatTheNumber((Double)item)
break;
}
}
Thanks in advance for your assistance!!!