Answers for "as c#"

C#
0

as c#

// taking a string variable 
string str1 = "GFG"; 

// taking an Object type variable 
// assigning var1 to it 
object obj1 = str1; 

// now try it to cast to a string 
string str2 = obj1 as string;

//here, 'as' is used to cast the object obj1 to a string,
//as the object already contained data of a string object
Posted by: Guest on January-18-2020

C# Answers by Framework

Browse Popular Code Answers by Language