struct MyStruct : int
{
.../...
}
MSDN声明之后是已实现接口的:
列表,但int
对我来说这是一个非常奇怪的接口......
这可能是一种定义结构大小的方法吗?有点像位域?
It is illegal and means nothing whatsoever.
Error 5 Type 'int' in interface list is not an interface redacted\Program.cs 13 23 ConsoleApplication9
However! If by int
you mean "an interface", then it means: "this is a value-type that implements an interface"
You can't, however, have an interface called int
, since int
is a reserved keyword. You would have to refer to that as @int
in the C#.
看起来 Struct 实际上应该说 Enum,那么它就会有意义。
这里struct MyStruct : int
不是一个接口,所以编译器会失败
如果你有 Resharper,它会在运行构建之前通过红色下划线来警告你
因为知识 int 是System.Int32的别名,它是一个结构