C# Language (How Do I in C# Express)
This page links to help on widely used C# Language tasks. To view other categories of popular tasks covered in Help, How Do I in C# Express.
Note
If you are using Visual C# Express Edition, some of the Help links on this page may be unavailable, depending on the options that you chose during installation. For more information, see Troubleshooting Visual C# Express.
The C# Language
What's New in Visual C#
Contains information about the new features, such as implicitly typed local variables, object initializers, extension methods, anonymous types, lambda expressions and query keywords.Visual C# Express Features
Introduces the main features of Visual C# Express Edition: The Visual C# compiler, the debugger, the integrated developer environment (IDE), support for Windows forms and controls, database support, consuming Web services and Class Designer.What's New in Visual C# Express
Describes the new features available in Visual C# Express Edition, such as Windows Presentation Foundation (WPF), Language-Integrated Query (LINQ), and Windows Communication Foundation (WCF) Services consumption.C# Compared to Other Languages
Introduces a comparison between C# and other languages such as C++, Visual Basic, and Java.C# and the .NET Framework
Provides an overview of the .NET Framework, and how to work with the .NET Framework and the common language runtime (CLR).Using LINQ in C#
Gives an overview of LINQ and provides links to topics that describe LINQ in more detail.C# Language Specification
Provides pointers to the latest version of the C# Language Specification in Microsoft Word format.
Anonymous Types
- How to: Return Subsets of Element Properties in a Query (C# Programming Guide)
Demonstrates how to use an anonymous type to return only a subset of the properties of each source element that matches the specified condition.
Command Line
Main() and Command-Line Arguments (C# Programming Guide)
Explains the Main method, the entry point of your program, where you create objects and invoke other methods. There can only be one entry point in a C# program.How to: Access Command-Line Arguments Using foreach (C# Programming Guide)
Provides a code example that shows how to access the command-line parameters.How to: Display Command Line Arguments (C# Programming Guide)
Explains how to display to the command-line arguments through the args string array.Main() Return Values (C# Programming Guide)
Explains the possible return values of the Main method.
Classes and Inheritance
base (C# Reference)
Explains how to specify the base-class constructor called when you are creating instances of a derived class.How to: Access a Collection Class with foreach (C# Programming Guide)
Contains a code example that illustrates how to write a collection class that can be used with foreach.How to: Know the Difference Between Passing a Struct and Passing a Class Reference to a Method (C# Programming Guide)
Contains a code example that shows that when a struct is passed to a method, a copy of the struct is passed, but when a class instance is passed, a reference is passed.Instance Constructors (C# Programming Guide)
Explains class constructors and inheritance.How to: Inherit from a Class
Includes a code example that defines the Circle and Rectangle classes, which both inherit from the Shape class, and the Square class, which inherits from the Rectangle class.
Interfaces
How to: Explicitly Implement Interface Members (C# Programming Guide)
Shows how to declare a class that explicitly implements an interface and how to access the members through the interface instance.How to: Explicitly Implement Members of Two Interfaces (C# Programming Guide)
Provides an example that displays the dimensions of a box in both metric and English units.
Lambda Expressions
How to: Use Lambda Expressions in a Query (C# Programming Guide)
Demonstrates how to use a lambda expression in a method-based query.How to: Use Lambda Expressions Outside LINQ (C# Programming Guide)
Illustrates how to use a lambda expression in a Windows Forms event handler.
Properties
How to: Declare and Use Read/Write Properties (C# Programming Guide)
Contains an example that shows you how to declare and use write-only and read-only properties.How to: Define Abstract Properties (C# Programming Guide)
Contains a code example that shows how to define abstract properties.
Strings
How to: Search Strings Using Regular Expressions (C# Programming Guide)
Explains how the Regex class can be used to search strings. These searches can range in complexity from very simple to making full use of regular expressions.How to: Concatenate Multiple Strings (C# Programming Guide)
Contains a code example that demonstrates how to join multiple strings.How to: Search Strings Using String Methods (C# Programming Guide)
Contains a code example that demonstrates how to use String methods to search for a string.How to: Split Strings (C# Programming Guide)
Contains a code example that demonstrates how a string can be parsed using the System.String.Split method.
Generics
default Keyword in Generic Code (C# Programming Guide)
Provides a code example that demonstrates how to use the default keyword for type parameters.Generic Methods (C# Programming Guide)
Introduces the syntax to declare a generic method. It also demonstrates an example that uses generic methods in an application.Constraints on Type Parameters (C# Programming Guide)
Shows how to constrain type parameters to enable access to methods and properties of the types that are used to instantiate the generic class.Generic Delegates (C# Programming Guide)
Contains the syntax to declare generic delegates and code examples. It also includes important remarks about instantiating and using generic delegates.
Events
How to: Raise Base Class Events in Derived Classes (C# Programming Guide)
Contains a code example that shows a class, ListWithChangedEvent, which resembles the standard ArrayList class but also invokes a Changed event whenever the contents of the list change.How to: Publish Events that Conform to .NET Framework Guidelines (C# Programming Guide)
Contains an example that creates a control that responds to events by following the .NET Framework guidelines.How to: Implement Interface Events (C# Programming Guide)
Shows how to declare an event in an interface and implement it in a class.
Extension Methods
How to: Implement and Call a Custom Extension Method (C# Programming Guide)
Shows how to implement your own extension methods for any .NET type that you want to extend.How to: Create a New Method for an Enumeration (C# Programming Guide)
Demonstrates how to add an extension method to an enumeration.
Namespaces
How to: Use the My Namespace (C# Programming Guide)
Provides an example that calls various static methods that are contained in the My namespace.How to: Use the Namespace Alias Qualifier (C# Programming Guide)
Discusses how to access a member in the global namespace when the member might be hidden by another entity of the same name.
Implicitly Typed Local Variables
- How to: Use Implicitly Typed Local Variables and Arrays in a Query Expression (C# Programming Guide)
Demonstrates how to use implicitly-typed local variables to store anonymous types, and to determine the type of a local variable.
Iterators
How to: Create an Iterator Block for a Generic List (C# Programming Guide)
Provides an example in which an array of integers is used to build the list SampleCollection. A for loop iterates through the collection and yields the value of each item. Then a foreach loop is used to display the items of the collection.How to: Create an Iterator Block for a Generic List (C# Programming Guide)
Provides an example in which a generic class Stack<T> implements a generic interface IEnumerator<T>. An array of the type T is declared and assigned values by using the Push method. In the GetEnumerator method, the values of the array are returned by using the yield return statement.
Delegates
Anonymous Functions (C# Programming Guide)
Describes how to use lambda expressions and anonymous methods to create delegate types.How to: Combine Delegates (Multicast Delegates)(C# Programming Guide)
Provides an example that demonstrates how to compose multicast delegates.How to: Declare, Instantiate, and Use a Delegate (C# Programming Guide)
Provides an example of how to declare, instantiate, and use a delegate.
Interoperability
- How to: Use Platform Invoke to Play a Wave File (C# Programming Guide)
Illustrates how to use platform invoke services to play a wave sound file on the Windows operating system.
Object and Collection Initializers
How to: Initialize Objects without Calling a Constructor (C# Programming Guide)
Illustrates how to use object initializers to initialize type objects in a declarative manner without having to invoke the type's constructor.How to: Initialize a Dictionary with a Collection Initializer (C# Programming Guide)
Demonstrates how to use a collection initializer to initialize a Dictionary.
Operator Overloading
- How to: Use Operator Overloading to Create a Complex Number Class (C# Programming Guide)
Shows how to use operator overloading to create a complex number class, Complex, that defines complex addition.
Threading
How to: Create and Terminate Threads (C# Programming Guide)
Provides an example that demonstrates how to create and start a thread, and shows the interaction between two threads running at the same time in the same process.How to: Use a Thread Pool (C# Programming Guide)
Explains an example that shows how to use a thread pool.
Working with DLLs
- How to: Create and Use C# DLLs (C# Programming Guide)
Demonstrates how to build and use a DLL by using an example scenario.
Unsafe code
How to: Use Pointers to Copy an Array of Bytes (C# Programming Guide)
Shows how to use pointers to copy bytes from one array to another by using pointers.How to: Use the Windows ReadFile Function (C# Programming Guide)
Shows how to call the Windows ReadFile function, which requires that you use an unsafe context because the read buffer requires a pointer as a parameter.
C# Programming Example Snippets
Designing a User Interface in Visual C#
Presents code examples for creating Windows forms applications in Visual C# Express Edition.TreeView Controls
Helps you find code that demonstrates how to perform common TreeView programming tasks by using Visual C# Express Edition.Button Controls
Helps you find code that demonstrates how to perform common Button programming tasks using Visual C# Express Edition.Text Controls
Helps you find code that demonstrates how to perform common TextBox and RichTextBox programming tasks by using Visual C# Express Edition.Dialog Boxes (Visual C#)
Helps you find code that demonstrates how to use built-in dialog boxes by using Visual C# Express Edition.Drawing Text and Graphics
Helps you find code that demonstrates how to perform common drawing-text programming tasks by using Visual C# Express Edition.Date and Time Controls
Helps you find code that demonstrates how to perform common DateTimePicker and MonthCalendar programming tasks by using Visual C# Express Edition.Creating a Custom UI
Helps you find code that demonstrates common UI programming tasks by using Visual C# Express Edition.Adding Multimedia to an Application
Helps you find code that demonstrates programming tasks for integrating multimedia into a Visual C# application.Accessing and Displaying Data
Helps you quickly find code examples about DataGrid controls and XML data features in Visual C# Express Edition.
Other Resources
These Web sites are excellent resources for finding more information, seeing what other Express users are doing, and stay in touch as Visual C# Express grows.
Visual C# Developer Center
Serves as a central location for information about Visual C# Express Edition. Includes videos, new tools, and other downloads.Beginner Developer Learning Center
Serves as a central location for learning materials for the beginner developer. Includes video tutorials, articles, the How-To Reference Library, and Kid's Corner.Coding4Fun
Includes lots of articles and coding tips for the Visual C# Express developer.