No Templates

One of the disappointments for C++ programmers moving to C# is the lack of templates. Templates provide the ability to create parameterized types. For example, if you create an integer array class, you might someday need a floating-point array class. Templates provided a clean way to accomplish this, without requiring you to cut and paste code from the integer array class to the floating-point array class. Templates generally were implemented in such a way that behind the scenes the compiler was in fact doing almost exactly that, but it wasn't something the programmer needed to get involved with.

It's extremely unlikely that templates will ever be added to C#. Currently, the developers of C# are looking at other alternatives for providing generic implementations that won't involve templates as such. The .NET Framework provides features such as array classes, so scenarios such as the preceding example won't likely present a problem. In other scenarios, however, some form of generics would be extremely useful.

0 0

Post a comment