New C# Features in the .NET Framework 4-Covariance and Contravariance

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

Difference between Data Encapsulation vs Abstraction

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

Runtime Vs Compile time Errors in C#

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#

Covariance and Contravariance FAQ

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

C# Programming Tools

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

Visual C# 2010 Samples

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