C# as关键字

你能进到这篇文章……

首先你可能明白类似于

1 double num=0;
2 int m=(int) num;

或者你明白 

1 int m=209;
2 String str=m.toString();

或者说你甚至见过

1 char m='c';
2 int m=Integer.parseInt(m);

现在应该明白as了吧? 对, 你没有猜错,它就是一种类型强转的方式。例子如下:

1 Object object=null;
2 string s = object as string;
3 if (s != null)
4 {
5     // object is a string.
6 }

猜你喜欢

转载自www.cnblogs.com/ybqjymy/p/12902830.html