dotnet / dotnet/docs

Discussion of the 2nd case is missing: User-defined conversions _from_ values of a base class

Open
#29,993 1 comment 0 reactions 0 assignees View on GitHub
dotnet-csharp/svc errors-warnings/subsvc
Dominant language
No language data
Stars
4.8k
Forks
6.1k
Avg merge
15h 21m
Merged PRs (30d)
370

Description

The page lists a trivial and easy to understand case. However a more realistic and useful case is not discussed at all: User-defined conversions _from_ values of a base class are not allowed. It would be nice to discuss why, and to provide reasonable workarounds!

In particular with emphasis on the fact that the base class may not provide convenience conversion methods to derived classes for at least 2 reasons:
- The fact that base classes may be in other assemblies
- The fact that derived classes may introduce type parameters that do not exist on the base class

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: eb04a5ff-461e-a70d-5e7c-20333e93c683
* Version Independent ID: d1a76803-3482-678d-b6b4-dd50b4d80fd8
* Content: [Compiler Error CS0553](https://docs.microsoft.com/en-us/dotnet/csharp/misc/cs0553?f1url=%3FappId%3Droslyn%26k%3Dk(CS0553))
* Content Source: [docs/csharp/misc/cs0553.md](https://github.com/dotnet/docs/blob/main/docs/csharp/misc/cs0553.md)
* Product: **dotnet-csharp**
* Technology: **csharp-diagnostics**
* GitHub Login: @BillWagner
* Microsoft Alias: **wiwagn**

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.