dotnet / dotnet/docs

Variance in Delegates introduced in 2.0, not 3.5

Open
#39,852 0 comments 0 reactions 0 assignees View on GitHub
:watch: Not Triaged
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

### Type of issue

Other (describe below)

### Description

### Describe the issue or suggestion

The article [Variance in Delegates (C#)](https://github.com/dotnet/docs/blob/main/docs/csharp/programming-guide/concepts/covariance-contravariance/variance-in-delegates.md) seems to have wrong information about when the support for variance in delegates was introduced - .NET Framework 3.5

From the CSharp Language specification, it seems to have been possible since 2005 or Csharp 2.0 and .NET Framework 2.0
From ECMA-334 ([3rd Edition June 2005](https://ecma-international.org/wp-content/uploads/ECMA-334_3rd_edition_june_2005.pdf)) 22.1 Delegate Declarations p.58:
"This definition of consistency allows covariance in return type and contravariance in parameter types."

Reding from the second edition of CLR via C# (March 22, 2006) p. 335
"Both C# and the CLR allow for covariance and contra-variance of reference types when binding a method to a delegate. Covariance means that a method can return a type that is derived from the delegate's return type. Contra-variance means that a method can take a parameter that is a base of the delegate's parameter type."

All this is before the release of .NET Framework 3.5 in 2007.

### Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/covariance-contravariance/variance-in-delegates

### Content source URL

https://github.com/dotnet/docs/blob/live/docs/csharp/programming-guide/concepts/covariance-contravariance/variance-in-delegates.md

### Document Version Independent Id

1fcbc3ff-e3f1-e0a7-7373-16ae150a0de8

### Article author

@wiwagn

### Metadata

* ID: 0e34cc1a-4658-d7ce-741d-8d81c1701682
* Service: **dotnet-csharp**
* Sub-service: **advanced-concepts**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.