Answer the question
In order to leave comments, you need to log in
Separate data types or one var?
It turned out that on real numbers in Russian wasps, you need to use not a dot, but commas.
My IDE (I use Rider because there are no ide norms for Linux) prompted me to replace double with var ... And now my question is: what is var, is it a universal variable or what is the essence of var (a) in general?
PS: Perhaps I will attach 2 small codes with and without var, so that it would be clear what I mean:
Code with var
using System;
public class MainClass
{
public static void Main()
{
var a = Convert.ToDouble(Console.ReadLine()); // Получаем ввод с клавиатуры но не используя тип переменной double а используя var как универсальное
var b = Convert.ToDouble(Console.ReadLine());
Console.WriteLine((a + b) / 2); //делаем все решение и выводим
}
}
using System;
public class MainClass
{
public static void Main()
{
double a = Convert.ToDouble(Console.ReadLine()); // Получаем ввод с клавиатуры но уже НЕ используя var
double b = Convert.ToDouble(Console.ReadLine());
Console.WriteLine((a + b) / 2); //делаем все решение и выводим
}
}
Answer the question
In order to leave comments, you need to log in
https://docs.microsoft.com/ru-ru/dotnet/csharp/lan...
var - says "there will be a variable next", and the compiler already determines the type of the variable.
In your specific example, it is clear that both variables are double from the right side of the assignment.
You can use var, but in order to better delve into the topic, it’s better to know what type of data you need to put in this or that situation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question