Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

.NET interview questions : - What is the use and difference between “IS” and “AS” keyword?

This question is taken from the book .NET interview questions written by Shivprasad Koirala.

“IS” keyword is useful to check if objects are compatible with a type. For instance in the below code we are checking if “ocust” object is a type of “Customer” class.

object ocust = new Customer();

if (ocust is Customer)
{

“AS” keyword helps to do conversion from one type to other type. For instance in the below code we are converting object to a string data type.

object o = "interview";
string str = o as string;

You can also see the below  youtube video created by www.questpond.com which explains the difference between "IS" and "AS" keyword practically.



We are thankful to http://www.questpond.com  for their continuous support to maintain this blog. They have c# and .NET interview question with answer video services , do visit our sponsor once.

Tags: c# interview question for freshers, c# interview questions for seniors, c# interview questions with answers, csharp interview questions, difference between "is" and "as" c# keyw, information technology questions, programming interview questions
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments