"IS" keyword can be used to check whether two variables are of same type.
Ex:
object obj="narendra";
object obj1=1234;
if(obj is string)
{
Console.WriteLine("Success");//this statement executes as obj is string
}
if(obj1 is string){
Console.WriteLine("Success");//this statement is not executed as obj1 is not string
}
"AS" keyword is used to convert variables from one type to another and if conversion is not successful then null is stored.
string str=obj as string;//here it succeeds and str has value of "narendra"
string str1=obj1 as string;// here it fails and str1 has null value
Subscribe to:
Post Comments (Atom)
Call a function in child component from parent component in React
Consider the following parent component class Parent extends React.Component { constructor(props) { super(props); thi...
-
Common Language Runtime or CLR is the run-time execution environment of .Net Framework. Converting MS-IL into platform or OS specific code ...
-
An object is an entity that has Properties for identifying State, Methods for behavior, Events for depicting the change of State. Data ass...
-
this error occurs when we are using a port and try to bind the same port again. I have this error when I was using react and using 9080 por...
No comments:
Post a Comment