C# Futures: Relaxed Overrides

A commonly requested feature in .NET is the ability to use covariant return types. An example of this would be overriding “virtual object Clone()” with “override Widget Clone()”. From a type safety perspective, this is perfectly acceptable, but C# doesn’t currently allow it.
 
Under the covariant return types proposal, this rule would be relaxed and your subclasses methods could offer more specific return types than the base class version of the same method. Beside Clone, this could be useful when working abstract factories and other framework code.
 
Continue here>> 
X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now