Visual C# Sample Applications

This topic describes available C# samples.

To access samples from Visual Studio

  1. On the Help menu, click Samples.

  2. In the Samples on Disk section of the readme file, click local Samples folder. By default, the samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\1033 or drive:\Program Files (x86)\Microsoft Visual Studio 10.0\Samples\1033.

  3. Right-click the .zip file that contains the samples you want to open and then click Extract All to extract the samples to a folder of your choice.

For the most current samples, see the Visual C# Samples Web site.

Security noteSecurity Note

Microsoft provides the included samples "AS IS" with no warranties. The code in the samples is provided just to illustrate concepts. The provided code may not meet security requirements for any specific environment. We recommend that you add security and error-handling code to your projects to make them as secure and robust as you deem appropriate.

Visual Studio 2010 Samples



Office Sample

Demonstrates new features that simplify access to Office API objects. For more information, see How to: Access Office Interop Objects by Using Visual C# 2010 Features (C# Programming Guide).

Python Sample

Shows how to use the dynamic (C# Reference) keyword to enable access to IronPython libraries and objects from C# code.

Variance Sample

Demonstrates how to create and use covariant and contravariant generic delegates. For more information, see Variance in Generic Interfaces (C# and Visual Basic) and Variance in Delegates (C# and Visual Basic).

Language Samples



Anonymous Delegates Sample

Demonstrates the use of unnamed delegates to reduce application complexity.

Arrays Sample

Shows how to use arrays.

Attributes Sample

Shows how to create custom attribute classes, use them in code, and query them through reflection.

Collection Classes Sample

Shows how to make non-generic collection classes that can be used with the foreach statement.

COM Interop Sample, Part 1

Shows how to use C# to interoperate with COM objects.

COM Interop Sample, Part 2

Shows how to a use a C# server together with a C++ COM client.

Command-Line Parameters Sample

Demonstrates simple command-line processing and array indexing.

Conditional Methods Sample

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 Sample

Shows how delegates are declared, mapped to static and instance methods, and combined into multicast delegates.

Events Sample

Shows how to declare, invoke, and configure events in C#.

Explicit Interface Implementation Sample

Demonstrates how to explicitly implement interface members and how to access those members from interface instances.

Generics Sample

Shows how to make generic collection classes that can be used with the foreach statement.

Hello World Sample

A Hello World application.

Indexers Sample

Shows how C# classes can declare indexers to provide array-like access to objects.

Indexed Properties Sample

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 Sample

Shows how to use compiler options to create a DLL from multiple source files; also, how to use the library in other programs.

Nullable Sample

Demonstrates value types, such as double and bool, that can be set to null.

OLE DB Sample

Demonstrates how to use a Microsoft Access database from C#. It shows how you can create a dataset and add tables to it from a database.

Operator Overloading Sample

Shows how user-defined classes can overload operators.

Partial Types Sample

Demonstrates how classes and structures can be defined in multiple C# source-code files.

Platform Invoke Sample

Shows how to call exported DLL functions from C#.

Properties Sample

Shows how properties are declared and used; also demonstrates abstract properties.

Security Sample

Discusses .NET Framework security and shows two ways to modify security permissions in C#: using permission classes and permission attributes.

Structs Sample

Shows how to use structs in C#.

Threading Sample

Demonstrates various thread activities such as creating and executing a thread, synchronizing threads, interacting between threads, and using a thread pool.

Unsafe Code Sample

Shows how to use unmanaged code (code that uses pointers) in C#.

User-Defined Conversions Sample

Shows how to define conversions to and from user-defined types.

Versioning Sample

Demonstrates versioning in C# by using the override and new keywords.

XML Documentation Sample

Shows how to document code by using XML.

Yield Sample

Demonstrates how to use the yield keyword to filter items in a collection.

See Also

Other Resources

Visual Studio 2010 Samples

Visual C# Walkthroughs