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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sumit JoshiRank #1,252 · 1.4K reputationPosted Sep 20, 2015, 11:07 PM EDT
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.Francis SusaimichaelRank #466 · 5.4K reputationPosted Sep 20, 2015, 2:54 PM EDT
Sujeet SumanRank #790 · 2.9K reputationPosted Sep 20, 2015, 10:32 PM EDT
if (num is int)
{
Response.Write("Num is integer");
}
string str = string.Empty;
if (obj is string)
{
str = obj as string;
Response.Write(str);
}
Munesh SharmaRank #174 · 13.9K reputationPosted Sep 20, 2015, 11:18 PM EDT
Sumit JoshiRank #1,252 · 1.4K reputationPosted Sep 20, 2015, 11:39 PM EDT
Anil KumarRank #942 · 2.2K reputationPosted Sep 22, 2015, 6:24 AM EDT