S
Saurabh
Hi All,
I quite like the idea of using the 'as' operator in C# and test for nullness
for example,
void MyFunction(Object o)
{
MyDataType dt = o as MyDataType;
if (dt == null)
{
DoSomething();
}
}
but I cannot use it on the value types. There is a similar situation as
above and I am expecting a System.Drawing.Point datatype whats the best way
to carry out the cast? Is it just cast it and catch the exception if it
throws an invalid cast exception.
Any comments / recommendations ?
TIA,
--Saurabh
I quite like the idea of using the 'as' operator in C# and test for nullness
for example,
void MyFunction(Object o)
{
MyDataType dt = o as MyDataType;
if (dt == null)
{
DoSomething();
}
}
but I cannot use it on the value types. There is a similar situation as
above and I am expecting a System.Drawing.Point datatype whats the best way
to carry out the cast? Is it just cast it and catch the exception if it
throws an invalid cast exception.
Any comments / recommendations ?
TIA,
--Saurabh