I am new to C#, but still
public class Logging
{
public static int Write(params object[] items)
{
return Console.Write(items);
}
}
seems just ok, but does not work.
Well it is not obvious that all instances or Write are defined in compile time, but they are.
If i call
Logging.Write("Hello world");
i got string
System.Object[]
as response
There are two problems with your code:
There is no overload of the Console.Write method that does not return
void(e.g.,int).There is no overload of the Console.Write method that takes an array of
object. The overload matching is the one taking a singleobjectwhich converts theobjecttostringby invoking the ToString method. The ToString method returns"System.Object[]"for an array ofobject.Are you trying to do something like this?
Example:
Output: