What is the use of IS and AS in C#
The text of this thread is not in this database — only its details are. Read it on the old site: What is the use of IS and AS in C#
The text of this thread is not in this database — only its details are. Read it on the old site: What is the use of IS and AS in C#
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sumit JoshiPosted Sep 21, 2015, 3:07 AM
is operator : The
isoperator in C# is used to check the object type and it returns aboolvalue: true if the object is the same type and false if not.For
nullobjects, it returnsfalse.as operator : The
If Find Helpful mark as Correct Answer.asoperator does the same job ofisoperator but the difference is instead ofbool, it returns the object if they are compatible to that type, else it returnsnull.Anil KumarPosted Sep 22, 2015, 10:24 AM
Sumit JoshiPosted Sep 21, 2015, 3:39 AM
Munesh SharmaPosted Sep 21, 2015, 3:18 AM
Sujeet SumanPosted Sep 21, 2015, 2:32 AM
if (num is int)
{
Response.Write("Num is integer");
}
string str = string.Empty;
if (obj is string)
{
str = obj as string;
Response.Write(str);
}
Francis SusaimichaelPosted Sep 20, 2015, 6:54 PM