C Sharp programming language

   

The title given to this article is incorrect due to technical limitations. The correct title is C# programming language.

C# (pronounced see-sharp) is an object-oriented programming language developed by Microsoft as part of their .NET initiative. Microsoft based C# on C++ and the Java programming language. C# was designed to balance power (the C++ influence) with rapid development (the Visual Basic and Java influences).

Program execution

The Microsoft C# compiler does not compile to object code which can be executed directly by the target computer. Instead, it is compiled to an intermediate representation. This form consists of metadata and instructions based upon a stack-based virtual machine. All .NET language compilers (which includes Visual Basic .NET, Managed C++, Delphi 8.Net as well as C#) compile to this intermediary code called Common Intermediate Language (CIL). To the casual observer the resulting program looks like a normal Windows executable and has an ".exe" extension just like a normal application (code libraries have the standard ".dll" extension). This is because the executable loader in Windows XP recognises the CIL executable and passes control to the .NET virtual machine. On older operating systems, the CIL executable has a native bootstrapper that runs the .NET virtual machine on that assembly.

When the program is executed, the .NET CLR (Common Language Runtime) compiles the intermediate code into binary code as it is run—just-in-time compilation (JIT). The resulting binary code is stored temporarily (in a memory cache), so if the program uses that portion of code again, the cached version is used. However this is only in effect during the runtime of the program. If a .NET application is run again, this compilation process is done again. The performance of a .NET program can be improved by precompiling the intermediate code to native code using a native code generator utility, but the .NET framework must still be installed for execution.

In addition to compiling intermediate code at runtime, the CLR provides other services. Security mechanisms are built into the CLR so that programs from a low trust source can still be run, with an attempt to limit their permissions. Remoting allows a program to execute code on a different computer over a network. Because code from all .NET languages is compiled to the same intermediate language CIL, code written in different .NET languages can interoperate with no loss in performance.

Code libraries

The .NET Framework is a class library which can be used from a .NET language to perform tasks from simple data representation and string manipulation to generating dynamic web pages (ASP .NET), XML parsing and reflection. The code is organised into a set of namespaces which group together classes with a similar function, e.g. System.Drawing for graphics, System.Collections for data structures and System.Windows.Forms for the Windows Forms system.

A further level of organisation is provided by the concept of an assembly. An assembly can be a single file or multiple files linked together (through al.exe) which may contain many namespaces and objects. Programs needing classes to perform a particular function might reference assemblies such as System.Drawing.dll and System.Windows.Forms.dll as well as the core library (known as mscorlib.dll in Microsoft's implementation).

Example

using System;

namespace Example
{
    public sealed class HelloWorld
    {
        string myString;

        public string Value
        {
            get
            {
                return myString;
            }
            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException();
                }
                else
                {
                    myString = value;
                }
            }
        }

        public HelloWorld()
        {
            myString = "Hello, world!";
        }

        public override String ToString()
        {
            return myString;
        }

        public static void Main()
        {
            HelloWorld myHelloWorld = new HelloWorld();
            Console.WriteLine(myHelloWorld.ToString());
            Console.WriteLine(myHelloWorld.Value);
            Console.WriteLine(myHelloWorld);
            myHelloWorld.Value = "Blah.";
            Console.WriteLine(myHelloWorld.ToString());
            Console.WriteLine(myHelloWorld.Value);
            Console.WriteLine(myHelloWorld);
        }

        //Output is:
        //Hello, world!
        //Hello, world!
        //Hello, world!
        //Blah.
        //Blah.
        //Blah.
    }
}

Standardization

Microsoft has submitted C# to the ECMA for formal standardization. In December 2001, ECMA released ECMA-334 C# Language Specification. C# became an ISO standard in 2003 (ISO/IEC 23270). There are independent implementations being worked on, including:

More recently, Microsoft has announced plans to add support for generics (similar to C++ templates), partial types and some other new features. Those additions were already proposed for ECMA/ISO standardization.

Politics

Many of Microsoft’s products and initiatives generate political attention, and C# is no exception. Due to C#’s close relationship with a commercial institution, political discussions continue regarding the legitimacy of C# standardization, its Java similarities, its future as a general-purpose language, and other various debates. Some security experts express skepticism as to the efficacy of the CLR's security mechanisms, and criticise their complexity.

Unlike proprietary languages such as Visual Basic or Java, Microsoft chose to open C# up to the standardization process. However, Microsoft is still a primary force driving changes and innovation in the language. Additionally, Microsoft has made it clear that C#, as well as the other .NET languages, is an important part of its software strategy for both internal use and external consumption. Microsoft takes an active role in marketing the language as part of its overall business strategy.

See also

External links


Major programming languages (more)

Ada | ALGOL | APL | AWK | BASIC | C | C++ | C# | COBOL | Delphi | Eiffel | Fortran | Haskell | IDL | Java | JavaScript | Lisp | LOGO | ML | Objective-C | Pascal | Perl | PHP | PL/I | Prolog | Python | Ruby | SAS | Scheme | sh | Simula | Smalltalk | SQL | Visual Basic




cs:Csharp da:C Sharp de:C-Sharp es:C Sharp eo:C Dieso Komputillingvo fr:C sharp it:C sharp he:C Sharp lt:C sharp nl:C sharp ja:C Sharp pl:C Sharp ru:C Sharp uk:C Sharp zh:C#

Retrieved from "http://www.mywiseowl.com/articles/C_Sharp_programming_language"

This page has been accessed 1702 times. This page was last modified 13:26, 24 Nov 2004. All text is available under the terms of the GNU Free Documentation License (see Copyrights for details).