在Java里,比如说你有个class叫Shape。
你可以用Shape.class做很多东西,比如说,创建实例啦,把它变成string放到HashMap里啦,调用类Method啦。C#里面有类似的东西吗?我知道C#里,有typeof()。
但typeof是需要实例。请问,有没有不需要实例的方法啊?
你可以用Shape.class做很多东西,比如说,创建实例啦,把它变成string放到HashMap里啦,调用类Method啦。C#里面有类似的东西吗?我知道C#里,有typeof()。
但typeof是需要实例。请问,有没有不需要实例的方法啊?
HashTable
还有就是泛型
List<T>
Java:
Shape.classC#:
Shape shpae = new Shape();
.
.
Type type = typeof(shape);
Shape shape= new Shape();typeof(shape) //语法错误
typeof(Shape) //对
不过,也有可能是因为我的class跟namespace重名,导致,我用typeof的时候,系统以为是namespace了。
谢了。