Базовые типы данных. Ввод и вывод. Арифметические операции. (C-Sharp): различия между версиями

Материал из Информационная безопасностя
Перейти к навигации Перейти к поиску
Строка 20: Строка 20:
 
int age = Convert.ToInt32(ageString);
 
int age = Convert.ToInt32(ageString);
 
Console.WriteLine("Your age = " + age);
 
Console.WriteLine("Your age = " + age);
 +
</syntaxhighlight>
 +
 +
<syntaxhighlight lang="c#" line>
 +
int x = Convert.ToInt32(Console.ReadLine());
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Версия 15:34, 23 июня 2022

Базовые типы данных

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 int x = Convert.ToInt32(Console.ReadLine());

Арифметические операции

1 fahrenheit = celcius*1.8 + 32;

Задачник