📜  as c# 代码示例

📅  最后修改于: 2022-03-11 14:49:12.650000             🧑  作者: Mango

代码示例1
// 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