K MANOHAR GOUD
9866550012
CSHARP VERSIONS AND FEATURES
| C# 2.0 | C# 3.0 | C# 4.0 | C# 5.0 | Future | |
|---|---|---|---|---|---|
| Features added |
|
|
|
|
|
CSHARP has the following syntax
- Semicolons are used to denote the end of a statement.
- Curly braces are used to group statements. Statements are commonly grouped into methods (functions), methods into classes, and classes into namespaces.
- Variables are assigned using an equals sign, but compared using two consecutive equals signs.
- Square brackets are used with arrays, both to declare them and to get a value at a given index in one of them.
CSHARP Distinguishing features
- By design, C# is the programming language that most directly reflects the underlying Common Language Infrastructure (CLI). Most of its intrinsic types correspond to value-types implemented by the CLI framework. However, the language specification does not state the code generation requirements of the compiler: that is, it does not state that a C# compiler must target a Common Language Runtime, or generate Common Intermediate Language (CIL), or generate any other specific format. Theoretically, a C# compiler could generate machine code like traditional compilers of C++ or Fortran. Some notable features of C# that distinguish it from C and C++ (and Java, where noted) are:
- C# supports strongly typed implicit variable declarations with the keyword var, and implicitly typed arrays with the keyword new[]followed by a collection initializer.
- Meta programming via C# attributes is part of the language. Many of these attributes duplicate the functionality of GCC's and VisualC++'s platform-dependent preprocessor directives.
- Like C++, and unlike Java, C# programmers must use the keyword virtual to allow methods to be overridden by subclasses.
- Extension methods in C# allow programmers to use static methods as if they were methods from a class's method table, allowing programmers to add methods to an object that they feel should exist on that object and its derivatives.
- The type dynamic allows for run-time method binding, allowing for JavaScript like method calls and run-time object composition.
- C# has strongly typed and verbose function pointer support via the keyword delegate.
- Like the Qt framework's pseudo-C++ signal and slot, C# has semantics specifically surrounding publish-subscribe style events, though C# uses delegates to do so.
- C# offers Java-like synchronized method calls, via the attribute [MethodImpl(MethodImplOptions.Synchronized)], and has support for mutually-exclusive locks via the keyword lock.
- The C# languages does not allow for global variables or functions. All methods and members must be declared within classes. Static members of public classes can substitute for global variables and functions.
- Local variables cannot shadow variables of the enclosing block, unlike C and C++.
- A C# namespace provides the same level of code isolation as a Java package or a C++ namespace, with very similar rules and features to a package.
- C# supports a strict Boolean data type, bool. Statements that take conditions, such as while and if, require an expression of a type that implements the true operator, such as the boolean type. While C++ also has a boolean type, it can be freely converted to and from integers, and expressions such as if(a) require only that a is convertible to bool, allowing a to be an int, or a pointer. C# disallows this "integer meaning true or false" approach, on the grounds that forcing programmers to use expressions that return exactly bool can prevent certain types of programming mistakes common in C or C++ such as if
(a = b)(use of assignment=instead of equality==). - In C#, memory address pointers can only be used within blocks specifically marked as unsafe, and programs with unsafe code need appropriate permissions to run. Most object access is done through safe object references, which always either point to a "live" object or have the well-defined null value; it is impossible to obtain a reference to a "dead" object (one that has been garbage collected), or to a random block of memory. An unsafe pointer can point to an instance of a value-type, array, string, or a block of memory allocated on a stack. Code that is not marked as unsafe can still store and manipulate pointers through theSystem.IntPtr type, but it cannot dereference them.
- Managed memory cannot be explicitly freed; instead, it is automatically garbage collected. Garbage collection addresses the problem of memory leaks by freeing the programmer of responsibility for releasing memory that is no longer needed.
- In addition to the try...catch construct to handle exceptions, C# has a try...finally construct to guarantee execution of the code in the finally block, whether an exception occurs or not.
- Multiple inheritance is not supported, although a class can implement any number of interfaces. This was a design decision by the language's lead architect to avoid complication and simplify architectural requirements throughout CLI. When implementing multiple interfaces that contain a method with the same signature, C# allows the programmer to implement each method depending on which interface that method is being called through, or, like Java, allows the programmer to implement the method once and have that be the single invocation on a call through any of the class's interfaces.
- C#, unlike Java, supports operator overloading. Only the most commonly overloaded operators in C++ may be overloaded in C#.
- C# is more type safe than C++. The only implicit conversions by default are those that are considered safe, such as widening of integers. This is enforced at compile-time, during JIT, and, in some cases, at runtime. No implicit conversions occur between booleans and integers, nor between enumeration members and integers (except for literal 0, which can be implicitly converted to any enumerated type). Any user-defined conversion must be explicitly marked as explicit or implicit, unlike C++ copy constructors and conversion operators, which are both implicit by default.
- C# has explicit support for covariance and contravariance in generic types, unlike C++ which has some degree of support for contravariance simply through the semantics of return types on virtual methods.
- In C#, as in other class-based OO languages such as Java and Scala, class/interface inheritance and class/interface subtyping completely agree, due to the nominality of the type system of these languages.
- Enumeration members are placed in their own scope.
- C# provides properties as syntactic sugar for a common pattern in which a pair of methods, accessor (getter) and mutator (setter) encapsulate operations on a single attribute of a class. No redundant method signatures for the getter/setter implementations need be written, and the property may be accessed using attribute syntax rather than more verbose method calls.
- Checked exceptions are not present in C# (in contrast to Java). This has been a conscious decision based on the issues of scalability and versionability.
- Though primarily an imperative language, since C# 3.0 it supports functional programming techniques through first-class function objects and lambda expressions.
.NET Framework versions
There have been seven significant releases of the .NET Framework, excluding service packs. The
framework includes the compilers, runtime, and libraries. Additionally, there are other profiles
such Silverlight which complicate matters.
- 1.0 - released in 2002
- 1.1 - released in 2003
- 2.0 - released in 2005, with a new CLR (to handle generics and nullable types) and compilers for C# 2 and VB 8.
- 3.0 - released in 2006, this is just 2.0 plus new libraries: Windows Presentation Foundation, Windows Communication Foundation, Workflow Foundation, and Cardspace
- 3.5 - released in 2007, this is 3.0 plus new libraries (primarily LINQ and some extra "base" libraries such as
TimeZoneInfo) and new compilers (for C# 3 and VB 9) - 4 - released in 2010, this includes a new CLR (v4), new libraries, and the DLR (Dynamic Language Runtime)
- 4.5 - released in 2012, this allows for WinRT development on Windows 8 as well as extra libraries - with much wider async APIs
C# language versions
There are five significant language versions:
- C# 1
- C# 2, introducing generics, nullable types, anonymous methods, iterator blocks and some other more minor features
- C# 3, introducing implicit typing, object and collection initializers, anonymous types, automatic properties, lambda expressions, extension methods, query expressions and some other minor features
- C# 4, introducing dynamic typing, optional parameters, named arguments, and generic variance
- C# 5, introducing asynchronous functions, caller info attributes, and a tweak to
foreachiteration variable capture
Visual Studio versions
For a long time, releases of Visual Studio were closely tied to framework releases.
- VS.NET 2002 - support for C# 1 and .NET 1.0
- VS.NET 2003 - support for C# 1 and .NET 1.1
- VS 2005 - support for C# 2 and .NET 2.0, and .NET 3.0 with an extension
- VS 2008 - support for C# 3 and .NET 2.0, 3.0 and 3.5 (multi-targeting)
- VS 2010 - support for C# 4 and .NET 2.0, 3.0, 3.5 and 4
- VS 2012 - support for C# 5 and .NET 2.0 to 4.5 (including WinRT on Windows 8), and portable class libraries
Practical limitations and working configurations:
- You can't use C# 2 features without at least VS 2005
- You can't use C# 3 features without VS 2008
- You can't ask VS 2005 or VS 2008 to target .NET 1.0 or 1.1
- You can't force VS 2008 to restrict you to only C# 2 features, or force VS 2005 to restrict you to C# 1 features
- Each version of Visual Studio has its own project file format and will upgrade your older projects when you first load them in that version. (The differences between VS 2003 and VS 2005 were significant; the differences between VS 2005 and VS 2008 are much smaller.)
- VS 2008 has special support (in project properties) for which framework version you want to target: 2.0, 3.0 or 3.5
- You can use most C# 3 features when targeting .NET 2.0 or 3.0, but not quite all
No comments:
Post a Comment