C
C#17mo ago
retr0________

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
Thinker17mo ago
where exactly is the error? Btw you should use (int, double, double) instead of Tuple<int, double, double>
retr0________
retr0________17mo ago
The two last Console.Writeline
Thinker
Thinker17mo ago
You have a typo {0] should be {0} although you should use $interpolation instead
MODiX
MODiX17mo 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________17mo ago
thanks i haven't seen it
Thinker
Thinker17mo ago
It makes putting stuff inside strings much easier
retr0________
retr0________17mo ago
okay its a nice idea