I have the following in an interface:
string GetTopic(string rk);
and this function:
public string GetTopic(string rk)
{
return string.Format("{0}.{1}.{2}",
rk.Substring(0, 2).TrimStart('0'),
rk.Substring(2, 2).TrimStart('0').PadLeft(1, '0'),
rk.Substring(4, 2).TrimStart('0').PadLeft(1, '0'));
}
I would like to add an optional second parameter, enabling the function to be called like this:
var a = GetTopic("010101")
or
var b = GetTopic("010101","test")
In the first case I would like to get the output “1.1.1” and in the second case the output “1.1.1 – test”.
Is this possible or do I need to make two functions and have one overload the other one? How can I specify the optional second parameter in my interface?
You can set a default:
so “anotherParam” will be test if you call:
And for your interace-definition:
MSDN: http://msdn.microsoft.com/de-de/library/dd264739.aspx