Adding a wrapper to an overloaded function
Posted
by Cev
on Stack Overflow
See other posts from Stack Overflow
or by Cev
Published on 2010-06-18T08:45:53Z
Indexed on
2010/06/18
8:53 UTC
Read the original article
Hit count: 167
c#
Say you had a timestamp function and then wanted to create a new function to combine your timestamp and Console.WriteLine()
, e.g.
public static void Write(string msg)
{
WriteTimeStamp();
Console.WriteLine( msg );
}
But the WriteLine()
method has 18 or so overloads, which will not be reflected in the signature of the wrapper function. How would you have the wrapper take non-strings and pass them on to WriteLine()
?
© Stack Overflow or respective owner