Type Inference with var
The var keyword lets the compiler infer the type from the initialisation expression.
var number = 10; // intvar text = "Hi"; // stringvar pi = 3.14; // doubleConsole.WriteLine($"{number}, {text}, {pi}");Run the Application
Section titled “Run the Application”dotnet runResult
Section titled “Result”10, Hi, 3.14