GNU Free Documentation License . .

C Sharp

: ,
  C#. - .
C#
:

:

:
-, ,

:

2001

():

:

4.0 (12 2010)

:

:

C++, Java[1][2][3], Delphi, Smalltalk

:

F#, Nemerle, Vala, Windows PowerShell

C# ( - . 19982001 Microsoft Microsoft .NET Framework ECMA-334 ISO/IEC 23270.

C# C- , C++ Java. , , ( ), , , , , , , , LINQ, , XML.

  C++, Java, Delphi, Smalltalk  #, , , , , C# ( C++).

[]

C# CLR , , , , CLR. , , C#, BCL. , CLR. , CLR 1.1 2.0 C#; . ( C# 3.0, , .NET.) CLR C#, .NET- , , «» . , C#, CLR , C# , VB.NET, J# .

[]

.

« » ( ) , , , .[4] C++, «++» , 1.

( ,  . .) , ♯ , # .[5] C# ECMA-334.[6] , (, [7]), .

, - « ».

[]

C# ECMA (ECMA-334)[8] ISO (ISO/IEC 23270)[9].

, , C#, :

[]

C# :

.NET Framework Visual Studio
ECMA ISO/IEC Microsoft
C# 1.0 2002 2003 2002 2002 .NET Framework 1.0 Visual Studio .NET 2002
C# 1.2 2003 2003 .NET Framework 1.1 Visual Studio .NET 2003
C# 2.0 2006 2006 2005[10] 2005 .NET Framework 2.0 Visual Studio 2005
C# 3.0 [11] 2007 2007 .NET Framework 3.5 Visual Studio 2008
C# 4.0 2010 2010 .NET Framework 4 Visual Studio 2010
C# 2.0 C# 3.0 C# 4.0 C# 4.5 ()

  • -
  • -
  • -

[] 1.0

C# 1998 COOL (C-style Object Oriented Language). 1.0 .NET 2000 , -; C# 1.0 Microsoft Visual Studio .NET 2002 .

C# Java 1.4, : , C# ( , ), ( , ), , , foreach, , , (boxing), , (DLL, COM) .

, C# C++, Java: , ( , C++), , , goto ( ). C#   , unsafe .

[] 2.0

C# 2.0 Microsoft 2003 ; 2004 - ( Whidbey), C# 2.0 7 2005 Visual Studio 2005 .NET 2.0.

2.0
  • ( ).
  • , (generics). C++, . , , , , ,  . .[12]
  • , yield, Python Ruby.
  • , .
  • '??': return obj1 ?? obj2; ( C# 1.0) return obj1!=null ? obj1 : obj2;.
  • ('nullable') - ( , , int? i = null;), -, null. SQL.
  • , .Net ( C#).
  • 64- , , 64- .

[] 3.0

2004 Microsoft C#3.0.[13] 2005 C# 3.0 - C# 3.0, Visual Studio 2005 .NET 2.0. Visual Studio 2008 .NET 3.5.

3.0

C# 3.0 :

Customer c = new Customer(); c.Name = "James"; c.Age=30;
Customer c = new Customer { Name = "James", Age = 30 };
listOfFoo.Where(delegate(Foo x) { return x.size > 10; });

listOfFoo.Where(x => x.size > 10);
  • :
- , , C#- (, SQL).
  • : var x = "hello"; string x = "hello";
  • : var x = new { Name = "James" };
  • this .
public static class StringExtensions
{
  public static int ToInt32(this string val)
  {
    return Int32.Parse(val);
  }
}
// ...
string s = "10";
int x = s.ToInt32();
  • : (private)
public string Name { get; private set; }

C# 3.0 C# 2.0 MSIL-;   . , LINQ , List.FindAll List.RemoveAll.

[] 4.0

C# 4.0 2008 , CTP- Visual Studio 2010.

Visual Basic 10.0 C# 4.0 2010 , Visual Studio 2010.

4.0[14]
  • , :
    • (Python, Ruby)
    • COM-
    • (reflection)
    • (DOM). dynamic.
  • COM interop
  • (Code Contracts)

:

dynamic calc = GetCalculator();
int sum = calc.Add(10, 20);  //  
public void SomeMethod(int x, int y = 5, int z = 7);  //  

[] «Hello, World!»

«Hello world» C# :

using System;
 
namespace Example
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Hello World!"); //     
            Console.ReadKey(); //    
        }
    }
}

Windows Forms:

using System;
using System.Windows.Forms;
 
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e) //  label  button  
        {
            label1.Text = "Hello, World!";
        }
    }
}

[]

C#:

[] .

[]

  1. « # C++ Java» ( «C# 2010: » («Accelerated C# 2010»)  .: , 2010.  . 592.  ISBN 978-5-8459-1638-9; . 17)
  2. « C#   C C++, Java.», : « C# Java . , C C++, . , , , .» ( «C# ».  .: . 2003.  . 20).
  3. #. : . . . : "", 2004. 752 . : . . . . ISBN 5-8459-0563-X (.) . 26-27.
  4. Kovacs, James C#/.NET History Lesson (September 7, 2007). 21 2011. 23 2011.
  5. Microsoft C# FAQ. Microsoft.( ) 25 2008.(   )
  6. C# Language Specification.  4th.  ECMA International, 2006.
  7. Visual C#.net Standard (JPEG). Microsoft (September 4, 2003). 21 2011. 18 2009.
  8. Standard ECMA-334 C# Language Specification, 4rd edition (June 2006)
  9. ISO/IEC 23270:2003, Information technology  C# Language Specification
  10. Microsoft C# 2.0 2.0. 1.2, .
  11. C# 3.0 4.0 ECMA ISO/IEC .
  12. Differences Between C++ Templates and C# Generics (C# Programming Guide)
  13. MSDN News
  14. C# Future
  15. Dot Net Anywhere

[]

[]