I'm having a Method, it has one parameter of type object
.
In that I have to find the object
is Value Type
or Reference Type
Public void MyMethod(object param)
{
if(param is Value Type)
{
// Do Some Operation related to Value Type
}
else if(param is Reference Type)
{
// Do Some Operation related to Reference Type
}
}
List of Value Types
List of Reference Types
You can use properties IsValueType
and IsClass
on Type
:
if(param.GetType().IsValueType)
{
// param is value type
}
else if(param.GetType().IsClass)
{
// param is reference type
}