C
C#17mo ago
♫Woozy♫

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
Moods
Moods17mo ago
Interpolation works, it’d look like this
Console.WriteLine($”You have {sum} years left till pension”);
Console.WriteLine($”You have {sum} years left till pension”);
♫Woozy♫
♫Woozy♫OP17mo ago
Just found out you can also do it like this Console.WriteLine("You have " + sum + " years left till pension"); is there a difference?
Angius
Angius17mo ago
Interpolation being less writing and less ambiguous
Pobiega
Pobiega17mo ago
Always prefer interpolation. And retiring at 65 in todays economy? kekw
Moods
Moods17mo ago
harold
Angius
Angius17mo ago
Not in Fr*nce, that's for sure when
Want results from more Discord servers?
Add your server