How do I write text, then a int, then more text in the same line?
Trying to have it print "You have sum years left till pension."
Console.WriteLine("What's your name?");
string name = Console.ReadLine();
Console.WriteLine($"Hello {name}, how old are you?");
string input = Console.ReadLine();
int num1 = int.Parse(input );
int num2 = 65;
int sum = num2 - num1;
Console.WriteLine("You have " + sum " years left till pension");
6 Replies
Interpolation works, it’d look like this
Just found out you can also do it like this
Console.WriteLine("You have " + sum + " years left till pension");
is there a difference?
Interpolation being less writing and less ambiguous
Always prefer interpolation.
And retiring at 65 in todays economy?
Not in Fr*nce, that's for sure