[英]What does it mean when angle brackets are used after an interface?
My sample code has the following: 我的示例代码具有以下内容:
public class IdentityUser : IdentityUser<string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>,
IUser,
IUser<string>
{
I understand that the IdentityUser must implement the IUser methods but can someone explain what it means: 我了解IdentityUser必须实现IUser方法,但有人可以解释其含义:
IdentityUser<string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>
The angle brackets are notation for generics. 尖括号是泛型的符号。 I recommend reading documentation on C# generics, such as http://msdn.microsoft.com/en-us/library/ms379564(v=vs.80).aspx .
我建议阅读有关C#泛型的文档,例如http://msdn.microsoft.com/zh-cn/library/ms379564(v=vs.80).aspx 。
Wherever IdentityUser
is defined is something similar to this: 定义
IdentityUser
位置与此类似:
public interface IdentityUser<A,B,C,D> {
// ...
}
So if you make the following class: 因此,如果您进行以下课程:
public class MyClass : IdentityUser<string, string, string, string> {
// ...
}
Then it is saying that MyClass
implements IdentityUser
and that the type variable A
is string
, the type variable B
is string
, and so on. 这就是说
MyClass
实现了IdentityUser
,类型变量A
是string
,类型变量B
是string
,依此类推。
That is not easy to explain, but it means that the type is a generic one. 这不容易解释,但这意味着该类型是通用类型。 You should read the relevant topic in the MSDN library for details or maybe the Wikipedia article for an overview of the concept in general.
您应该阅读MSDN库中的相关主题以获取详细信息,或者应该阅读Wikipedia文章以大致了解该概念。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.