1 / 14

Язык программирования C #

Язык программирования C #. Дмитрий Сошников dmitryso@microsoft.com. Платформа .NET. C#. Visual Basic .NET. F#. Managed C++. …. Платформа Microsoft .NET. Исполнитель byte-code. Библиотека. Операционная система. Аппаратура компьютера (процессор, память, …). Особенности C#.

nida
Télécharger la présentation

Язык программирования C #

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Язык программирования C# Дмитрий Сошников dmitryso@microsoft.com

  2. Платформа .NET C# Visual Basic .NET F# Managed C++ … Платформа Microsoft .NET Исполнитель byte-code Библиотека Операционная система Аппаратура компьютера (процессор, память, …)

  3. Особенности C# • Мультипарадигмальный язык • Императивный • Объектно-ориентированный • Функциональный • Что нужно для программирования? • .NET Framework SDK • Visual Studio Professional/Ultimate (2010) • Visual Studio C# Express (2010)

  4. Минимальная программа на C# using System; namespaceMyApplication { classProgram { staticvoid Main(string[] args) { Console.WriteLine("Hello, World!"); } } }

  5. Переменные и типы данных • int – целый тип • float – вещественный тип • double – вещественный с двойной точностью • bool – логический (значения true/false) • Массивы, ссылки, делегаты, … • Объектный • MyObject, List<bool>, …

  6. Оператор присваивания using System; namespaceMyApplication { classProgram { staticvoid Main(string[] args) { float a = float.Parse(args[0]); float b = float.Parse(args[1]); float c = float.Parse(args[2]); var d = b * b - 4 * a * c; var x1 = -b + Math.Sqrt(d) / 2 / a; var x2 = -b - Math.Sqrt(d) / 2 / a; Console.WriteLine("x1={0}, x2={1}", x1, x2); } } }

  7. Операторы передачи управления • Условный оператор if-then-else • Циклы • С предусловием while … do • С постусловием do … while • Со счётчиком for

  8. Условный оператор using System; namespaceMyApplication { classProgram { staticvoid Main(string[] args) { float a = float.Parse(args[0]); float b = float.Parse(args[1]); float c = float.Parse(args[2]); var d = b * b - 4 * a * c; if (d>=0) { var x1 = -b + Math.Sqrt(d) / 2 / a; var x2 = -b - Math.Sqrt(d) / 2 / a; Console.WriteLine("x1={0}, x2={1}", x1, x2); } elseConsole.WriteLine("No solutions"); } } }

  9. Цикл со счётчиком, функции using System; namespace ConsoleApplication2 { classProgram { staticint fact(int x) { int f = 1; for (int i = 1; i <= x; i++) { f = f * i; } return f; } staticvoid Main(string[] args) { for (var i = 1; i < 10; i++) { Console.WriteLine("{0}!={1}", i, fact(i)); } Console.ReadKey(); } } }

  10. Классы, объекты classPerson { public Person(string n) { Name = n; } public Person(string n, Person f, Person m) { Name = n; Father = f; Mother = m; } publicPerson Father, Mother; publicstring Name { get; set; } publicvoid Introduce() { Console.WriteLine("I am {0}, my father is {1}, mother is {2}", Name, Father.Name, Mother.Name); } } varV = newPerson("Vasya",newPerson("Petya"), newPerson("Masha")); V.Introduce();

  11. Полезные классы в библиотеке • Списки List<…> • Словари Dictionary<TKey,TValue> • Работа с XML, сетевыми подключениями, сжатие данных, криптография, графика, … varL = newList<Person>(); L.Add(V); L.Add(newPerson("Jack",V,newPerson("Katya"))); L.Sort(newComparison<Person>((p1, p2) => string.Compare(p1.Name, p2.Name))); foreach(var x in L) Console.WriteLine(x.Name); L.ForEach(P => P.Introduce());

  12. C# - не только для консольного программирования! • Windows Forms • Windows Presentation Foundation • ASP.NET Web Forms • ASP.NET MVC • Silverlight • XNA Game Studio (Windows, XBox, Windows Phone 7, Zune) • Windows Phone 7 (Silverlight, XNA) • XBox (XNA)

  13. Дополнительные ресурсы для изучения • Центр начинающего разработчика: http://msdn.microsoft.com/ru-ru/beginner/default.aspx • Книга «C# для начинающих» – скачать PDF или читать онлайн http://msdn.microsoft.com/ru-ru/beginner/ee344863.aspx • Интернет-университет Intuit.ru • Основы программирования на C#: http://www.intuit.ru/department/pl/csharp/ • Введение в программирование на C# 2.0: http://www.intuit.ru/department/pl/csharp20/ • MSDN: • Центр Visual C#: http://msdn.microsoft.com/ru-ru/vcsharp/default.aspx • Интерактивный учебник по C#

  14. Console.WriteLine(“Thank.You!”); Дмитрий Сошников • dmitryso@microsoft.com, dmitri@soshnikov.com • http://www.soshnikov.com • http://blogs.msdn.com/sos • http://twitter.com/shwars

More Related