相关疑难解决方法(0)

为什么TEventArgs在.NET生态系统的标准事件模式中没有逆变?

在.NET中了解有关标准事件模型的更多信息时,我发现在引入C#中的泛型之前,处理事件的方法由此委托类型表示:

//
// Summary:
//     Represents the method that will handle an event that has no event data.
//
// Parameters:
//   sender:
//     The source of the event.
//
//   e:
//     An object that contains no event data.
public delegate void EventHandler(object sender, EventArgs e);
Run Code Online (Sandbox Code Playgroud)

但是在C#2中引入泛型之后,我认为这个委托类型是使用泛型重写的:

//
// Summary:
//     Represents the method that will handle an event when the event provides data.
//
// Parameters:
//   sender:
//     The source of the event.
//
//   e:
// …
Run Code Online (Sandbox Code Playgroud)

.net c# contravariance .net-core

23
推荐指数
1
解决办法
918
查看次数

C#4.0是否向后兼容C#2.0?

我可以知道C#4.0和C#2.0之间的区别是什么?C#4.0是否向后兼容C#2.0?

我可以说C#4.0是C#2.0的超集(就像C++到C的那样)吗?

谢谢.

c# c#-2.0 c#-4.0

8
推荐指数
2
解决办法
2749
查看次数

标签 统计

c# ×2

.net ×1

.net-core ×1

c#-2.0 ×1

c#-4.0 ×1

contravariance ×1