Covariance and Contravariance Covariance and contravariance are best introduced with an example, and the best is in the framework. In System.Collections.Generic, IEnumerable<T> and IEnumerator <T> represent, respectively, an object that’s a sequence of T’s and the enumerator (or iterator) that does the work of iterating the sequence. These interfaces have done a lot of heavy … Read more New C# Features in the .NET Framework 4-Covariance and Contravariance
Encapsulation has two faces; data abstraction and information hiding. Data abstraction is a type seen from the outside. Information hiding is a type seen from the inside. Sometime encapsulation is used to mean information hiding only but I think the definition I gave is better because if you encapsulate something you get both an inside … Read more Difference between Data Encapsulation vs Abstraction
The difference between compile time and run time is an example of what pointy-headed theorists call thephase distinction. It is one of the hardest concepts to learn, especially for people without much background in programming languages. To approach this problem, I find it helpful to ask What invariants does the program satisfy? What can go … Read more Runtime Vs Compile time Errors in C#
What are covariance and contravariance? In C#, covariance and contravariance enable implicit reference conversion for array types, delegate types, and generic type arguments.Covariance preserves assignment compatibility and contravariance reverses it. The following code demonstrates the difference between assignment compatibility, covariance, and contravariance. // Assignment compatibility. string str = “test”; // An object of a more … Read more Covariance and Contravariance FAQ
The C# Team has scoured the Web for other implementations of the CLI, cool object browsers, IDE tricks, add-ins, obfuscators, and other useful tools and utilities that will help you get your job done faster. Check out the Classes and Libraries page for more links to useful tools, frameworks, and class libraries, including code-generation tools. Featured … Read more C# Programming Tools
The Visual Studio 2010 RTM Samples are now live! Samples and documents for C# 4.0 can be found on the Downloads page. The CSharpDynamic samples include several projects showing how to use Dynamic with Office, IronPython and other technologies. There is also a covariance and contravariance example, and an example show how to use the new … Read more Visual C# 2010 Samples
Visual Studio 2010 is here! And of course this means that C# 4.0 is also here. Let’s do a quick review of the new language features added in this release. Dynamic The dynamic keyword is a key feature of this release. It closes the gap between dynamic and statically-typed languages. Now you can create dynamic … Read more Get Ready For C# 4.0!