So what I am assuming is if another method calls TestOutput() the first is called if it calls TestOutput(strUserName) then the second function is called.
I would have to assume also that you could not have two TestOutput methods with both taking a string, but one could have a string and the other an integer.
VS.NET does not supply a means for doing this automatically, but here's an MSDN article on how to create a macro to achieve what you are looking to do:
Could you explain to me what the writer means by "calling another overload of the same routine" I understand how both methods work but I would have thought the second method PrintItemsInSelectedProject would need to be called something else before the first methind would be able to call it.
1) C# doesn't have optional parameters, only VB.NET does. This is why you'll often see far more methods in a C# project than a VB.NET project.
2) You are correct, you could not have 2 methods of the same name both with a String as a parameter. Each method would need a different set of parameters.
There are 2 functions with the same name, but different parameters: Sub PrintItemsInSelectedProject() and Sub PrintItemsInSelectedProject(ByVal projitems As ProjectItems)
The author is attempting to state that the first function is calling the 2nd, and the 2nd function is just an overload of the first.
Print Solution
Paul P.S.
Avi Jain 10
zeroonezero
private void TestOutput(optional String strHelloName)
to cover both conditions
So what I am assuming is if another method calls TestOutput() the first is called if it calls TestOutput(strUserName) then the second function is called.
I would have to assume also that you could not have two TestOutput methods with both taking a string, but one could have a string and the other an integer.
Sivarv
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dncodefun/html/code4fun05302003.asp
Hope this helps,
Josh
hmcheung
Linda Call
1) C# doesn't have optional parameters, only VB.NET does. This is why you'll often see far more methods in a C# project than a VB.NET project.
2) You are correct, you could not have 2 methods of the same name both with a String as a parameter. Each method would need a different set of parameters.
Sven Beneke
This is very common in C#. For example:
private void TestOutput()
{
Console.WriteLine("Hello World");
}
private void TestOutput(String strHelloName)
{
Console.WriteLine("Hello " + strHelloName);
}
Chev
Sub PrintItemsInSelectedProject()
and
Sub PrintItemsInSelectedProject(ByVal projitems As ProjectItems)
The author is attempting to state that the first function is calling the 2nd, and the 2nd function is just an overload of the first.
Glad I could help,
Josh Lindenmuth