C#
syntax is highly expressive, yet it is also simple and easy to learn.
The curly-brace syntax of C# will be instantly recognizable to anyone
familiar with C, C++ or Java. Developers who know any of these languages
are typically able to begin to work productively in C# within a very
short time. C# syntax simplifies many of the complexities of C++ and
provides powerful features such as nullable value types, enumerations,
delegates, lambda expressions and direct memory access, which are not
found in Java. C# supports generic methods and types, which provide
increased type safety and performance, and iterators, which enable
implementers of collection classes to define custom iteration behaviors
that are simple to use by client code. Language-Integrated Query (LINQ)
expressions make the strongly-typed query a first-class language
construct.
As an object-oriented language, C# supports the concepts of encapsulation, inheritance, and polymorphism. All variables and methods, including the Main method, the application's entry point, are encapsulated within class definitions. A class may inherit directly from one parent class, but it may implement any number of interfaces. Methods that override virtual methods in a parent class require the override keyword as a way to avoid accidental redefinition. In C#, a struct is like a lightweight class; it is a stack-allocated type that can implement interfaces but does not support inheritance.
In addition to these basic object-oriented principles, C# makes it easy to develop software components through several innovative language constructs, including the following:
The C# build process is simple compared to C and C++ and more flexible than in Java. There are no separate header files, and no requirement that methods and types be declared in a particular order. A C# source file may define any number of classes, structs, interfaces, and events.
The following are additional C# resources:
As an object-oriented language, C# supports the concepts of encapsulation, inheritance, and polymorphism. All variables and methods, including the Main method, the application's entry point, are encapsulated within class definitions. A class may inherit directly from one parent class, but it may implement any number of interfaces. Methods that override virtual methods in a parent class require the override keyword as a way to avoid accidental redefinition. In C#, a struct is like a lightweight class; it is a stack-allocated type that can implement interfaces but does not support inheritance.
In addition to these basic object-oriented principles, C# makes it easy to develop software components through several innovative language constructs, including the following:
- Encapsulated method signatures called delegates, which enable type-safe event notifications.
- Properties, which serve as accessors for private member variables.
- Attributes, which provide declarative metadata about types at run time.
- Inline XML documentation comments.
- Language-Integrated Query (LINQ) which provides built-in query capabilities across a variety of data sources.
The C# build process is simple compared to C and C++ and more flexible than in Java. There are no separate header files, and no requirement that methods and types be declared in a particular order. A C# source file may define any number of classes, structs, interfaces, and events.
The following are additional C# resources:
- For a good general introduction to the language, see Chapter 1 of the C# Language Specification.
- For detailed information about specific aspects of the C# language, see the C# Reference.
- For more information about LINQ, see LINQ (Language-Integrated Query).
- To find the latest articles and resources from the Visual C# team, see the Visual C# Developer Center.