myobjects[2] = "hello";
myobjects[3] = 123;
myobjects[4] = 123.4;
myobjects[5] = null;
for (int i=0; i<myobjects.length; ++i)
{
string s = myobjects[i] as string;
console.write ("{0}:", i);
if (s != null)
console.writeline ( "'" + s + "'" );
else
console.writeline ( "not a string" );
}
}
}
输出
0:not a string
1:not a string
2:'hello'
3:not a string
4:not a string
5:not a string
14.new 操作符
new操作符用于创建一个新的类型实例,有三种形式: