Alex Rivera | Logout

Difference between is and as keyword

Asked 2010-09-24T10:59:49.080
131

Please tell what is the difference between is and as keyword in C#

Edit
Report

1 Answer

1

is: The is operator is used to check whether the run-time type of an object is compatible with a given type

as: The as operator is used to perform conversions between compatible types.

object s = "this is a test";
string str=string.Empty;
if( s is string)
    str = s as string;
answered 2010-09-24T11:05:39.820

Your Answer