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 IDynamicObject interface to create native C# objects that can be called dynamically.
The document New Features in C# 4.0 is a high level description of the additions to the C# language, and the samples are designed to show off the new language features, particularly around the dynamic scenario.
Please submit bugs through Microsoft Connect, or provide comments in the discussion section of this site.
Visual Studio 2010 Samples for C# 4.0
We break out the C# samples into two different categories:
Language Samples
LINQ Samples
Language Samples
The language samples familiarize you with various C# language features. They are available in the LanguageSamples folder.
The C# 4.0-specific samples are called:
Named and Optional
Office Sample
Python Sample
Simple Variance
Here is the complete list of language samples:
Anonymous Delegates: Demonstrates the use of unnamed delegates to reduce application complexity.
Arrays: Shows how to use arrays.
Attributes: Shows how to create custom attribute classes, use them in code, and query them through reflection.
Collection Classes: Shows how to make non-generic collection classes that can be used with the foreach statement.
COM Interop Part I: Shows how to use C# to interoperate with COM objects.
COM Interop Part II: Shows how to a use a C# server together with a C++ COM client.
Commandline: Demonstrates simple command-line processing and array indexing.
Condiational Methods: Demonstrates conditional methods, which provide a powerful mechanism by which calls to methods can be included or omitted depending on whether a symbol is defined.
Delegates: Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.
Events: Shows how to declare, invoke, and configure events in C#.
Explicit Interface: Demonstrates how to explicitly implement interface members and how to access those members from interface instances.
Generics: Shows how to make generic collection classes that can be used with the foreach statement.
Hello World: A Hello World application.
Indexers Part I: Shows how C# classes can declare indexers to provide array-like access to objects.
Indexers Part II: Shows how to implement a class that uses indexed properties. Indexed properties enable you to use a class that represents an array-like collection.
Libraries: Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs
Named and Optional (C# 4.0): Demonstrates Named and Optional parameters, an alternative to method overloads
Nullable: Demonstrates value types, such as double and bool, that can be set to null
Office Sample (C# 4.0): Demonstrates how Dynamic and COM Interop make it easy to call Microsoft Office in C# 4.0
OLEDB: Demonstrates how to use a Microsoft Access database from C# by creating a dataset and adding tables to it.
Operator Overloading: Shows how user-defined classes can overload operators
Partial Types: Demonstrates how classes and structures can be defined in multiple C# source-code files
PInvoke: Shows how to call exported DLL functions from C#
Properties: Shows how properties are declared and used; also demonstrates abstract properties
Python Sample (C# 4.0): Learn how to call a Python script by using the Dynamic feature in C# 4.0
Security: Discusses .NET Framework security and shows how to modify security permissions in C# by using permission classes and permission attributes
Simple Variance (C# 4.0): See how Covariance and Contravariance are supported in generic interfaces and delegates
Structs: Shows how to use structs in C#.
Threading: Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool
Unsafe: Shows how to use unmanaged code (code that uses pointers) in C#
User Conversions: Shows how to define conversions to and from user-defined types
Versioning: Demonstrates versioning in C# by using the override and new keywords
XML Documents: Shows how to document code by using XML
Yield: Demonstrates how to use the yield keyword to filter items in a collection
Read more: MSDN