[英]Separate GUIDs in Generic classes in C#
我创建了以下 class:
[Guid("4469031d-23e0-483c-8566-ce978ccc9a6f")]
class MyGenericContianer<BasicType> : SomeOtherContainer
{
}
这会导致以下两个类具有相同的 GUID:
MyGenericContianer<int> x;
MyGenericContianer<float> y;
我需要每种特定类型都有自己的 GUID。 你会怎么做?
您需要使用 inheritance 执行此操作。
class MyGenericContianer<BasicType> : SomeOtherContainer { }
[Guid("4469031d-23e0-483c-8566-ce978ccc9a6f")]
class Container1: MyGenericContainer<X> { }
[Guid("5569031d-23e0-483c-8566-ce978ccc9a6f")]
class Container2: MyGenericContainer<Y> { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.