Error : Seems like Console.Writeline don't see enought argument

Hello. I am beginner on C#. This is an exercice to understand class legacy. On the two last Console.Writeline, its seems like Console.Writeline don't see enought argument (CA2241) so when i run the program i have an exeption. But i don't understand why. Can you help me?
7 Replies
Thinker
Thinker2y ago
where exactly is the error? Btw you should use (int, double, double) instead of Tuple<int, double, double>
retr0________
retr0________OP2y ago
The two last Console.Writeline
Thinker
Thinker2y ago
You have a typo {0] should be {0} although you should use $interpolation instead
MODiX
MODiX2y ago
String interpolation is the preferred way of building strings in C#. It is easier to read than concatenation. For example:
var foo = 1;
var bar = 2;
Console.WriteLine("foo is equal to: " + foo + " and bar is equal to: " + bar);
var foo = 1;
var bar = 2;
Console.WriteLine("foo is equal to: " + foo + " and bar is equal to: " + bar);
can be written as:
var foo = 1;
var bar = 2;
Console.WriteLine($"foo is equal to: {foo} and bar is equal to: {bar}");
var foo = 1;
var bar = 2;
Console.WriteLine($"foo is equal to: {foo} and bar is equal to: {bar}");
retr0________
retr0________OP2y ago
thanks i haven't seen it
Thinker
Thinker2y ago
It makes putting stuff inside strings much easier
retr0________
retr0________OP2y ago
okay its a nice idea
Want results from more Discord servers?
Add your server