Tutorial :What C# features would be removed if backwards compatibility were not an issue? [closed]



Question:

Backwards compatibility is a big concern for language designers, especially when the language is as popular as C#. Over time languages accumulate obsolete features. It's considered good practice to avoid these features, but they are kept in the langage for compatibility with old releases.

Which language features or base class libraries in C# should be removed if backwards compatibility were not an issue?

I am not asking about features that some developers like and others loathe. I am interested in features that are (pretty much) universally regarded as best-avoided (perhaps because there is now an outright better way of doing the same thing).


Solution:1

ArrayList.

There is no point in using it anymore. List<> is way better.


Solution:2

I have heard several of the C# designers mention that they regret making arrays covariant.


Solution:3

I know this is an obvious answer but any class, property or method marked with the [Obsolete] attribute would probably be the first to be removed.


Solution:4

Non-sealed types by default.


Solution:5

When implementing IEnumerable<T>, you'll have to implement IEnumerator<T> GetEnumerator() as well System.Collections.IEnumerator GetEnumerator() for backwards compatibility reasons.


Solution:6

The ReaderWriterLock class is basically pointless now in favor of the ReaderWriterLockSlim class, which Microsoft themselves say is recommended for all new development.


Solution:7

Named attribute constructor parameters.

Currently, you set the named parameters with:

[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]  

This is from the time of C#1, but now there are object constructors:

new Foo(explicit, values) { Implicit = value }  

Which would result in the following Attribute constructor:

[AttributeUsage(AttributeTargets.Method) { Inherited = false, AllowMultiple = true }]  


Solution:8

The System.IO.Path.InvalidPathChars field. Using it results in a security risk, but there's nothing they can do about it for compatibility reasons.


Solution:9

From the BCL's:

  1. COM Interop
  2. StringCollection (Generic List)
  3. StringDictionary (Generic Dictionary)


Solution:10

Generic lists (as mentioned by Reshure) including "var". I'm a proponent of explicitly declaring variables.

Edit: I think people are equating "generic lists" with "generics". If you prefer, "untyped collections" such as Hashtable or ArrayList.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »