I am getting errors trying to overload the function Print(object) in the new .NET 6 C# console app template (top-level statements).
void Print(object obj) => Print(obj, ConsoleColor.White);
void Print(object obj, ConsoleColor color)
{
Console.ForegroundColor = color;
Console.WriteLine(obj);
Console.ResetColor();
}
Errors are:
- From
Print(obj, ConsoleColor.White)->No overload for method Print() that takes 2 arguments - From
Print(object obj, ConsoleColor color)->A local variable or function named 'Print' is already defined in this scope
I tried to switch their order but it still throws errors. What's going on?