What is the difference between Is and as Keyword in C# ?


One time i got this question in interview. Answer of this question , i have implemented in this code like this

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//The is operator is used to check whether the run-time type of an object is compatible with a given

object num=10;
if (num is int)
Response.Write(“Num is integer”);

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

object ss = “This sis the string”;
string str = string.Empty;
if (ss is string)
str = ss as string;