C-Sharp: различия между версиями
		
		
		
		
		
		Перейти к навигации
		Перейти к поиску
		
				
		
		
	
| (не показаны 4 промежуточные версии этого же участника) | |||
| Строка 1: | Строка 1: | ||
| + | {{TOCRight}}  | ||
| + | |||
| + | == IDE ==  | ||
| + | * [https://visualstudio.microsoft.com/vs/community/ Visual Studio Community]  | ||
| + | * [https://www.jetbrains.com/rider/ JetBrains Rider]  | ||
| + | |||
| + | == C# - 101 ==  | ||
| + | * [https://channel9.msdn.com/Series/CSharp-101 Channel9 MSDN]  | ||
| + | |||
== Hello World ==  | == Hello World ==  | ||
| − | * [[Hello  | + | * [[Hello - C-Sharp]]  | 
== Объявление переменных ==  | == Объявление переменных ==  | ||
| Строка 11: | Строка 20: | ||
char firstLetter = 'C';  | char firstLetter = 'C';  | ||
string name = "Hi, there!";  | string name = "Hi, there!";  | ||
| − | int[] age = new int[5]   | + | int[] age = new int[5];  | 
int[] age2 = {3, 7, 15, 21, 7};  | int[] age2 = {3, 7, 15, 21, 7};  | ||
</syntaxhighlight>  | </syntaxhighlight>  | ||
Текущая версия на 12:13, 30 марта 2021
IDE
C# - 101
Hello World
Объявление переменных
1 int a = 5;
2 double b = a / 2; 
3 bool test = true;
4 char firstLetter = 'C';
5 string name = "Hi, there!";
6 int[] age = new int[5];
7 int[] age2 = {3, 7, 15, 21, 7};
Ввод и вывод
1 Console.WriteLine("Please, enter your age:");
2 string ageString = Console.ReadLine();
3 int age = Convert.ToInt32(ageString);
4 Console.WriteLine("Your age = " + age);
Условный оператор
 1 Console.WriteLine("Please, enter your age:");
 2 string ageString = Console.ReadLine();
 3 int age = Convert.ToInt32(ageString);
 4 if (age > 65)
 5 {
 6     Console.WriteLine("Here is your pension.");
 7 }
 8 else
 9 {
10     Console.WriteLine("Good morning people!");
11 }
Циклы
 1 Console.WriteLine("while loop");
 2 i = 1;
 3 while (i < 11)
 4 {
 5     Console.WriteLine(i);
 6     i++;
 7 }
 8 
 9 Console.WriteLine("do while loop");
10 i = 1;
11 do
12 {
13     Console.WriteLine(i);
14     i++;
15 } while (i < 11);
16 
17 Console.WriteLine("for loop");
18 for (int j = 1; j < 11; j++)
19 {
20     Console.WriteLine(j);
21 }