We VB.netters have been having them for years, kinda boring actualy. But I guess you C# guys find them all new and exiting.
Here a small number of the blogs in the blogsphere about them.
- C# 4.0 Optional Parameters and C# 4.0 Named Parameters
- Named and optional parameters in C# 4.0
- C# 4.0 Optional Parameters
This works in VB.Net 2008 (VB9) and VB.Net 2010 (VB10).
Optional parameters have been in VB for a long time not sure when named parameters came in.
```vbnet Module Module1
Sub Main()
Console.WriteLine(test)
Console.WriteLine(test(b:=3))
Console.ReadLine()
End Sub
Public Function test(Optional ByVal a As Integer = 1, Optional ByVal b As Integer = 2)
Return a + b
End Function
End Module``` So now C# can do this too. And now they can actualy use a vb dll to its full extent.
The following only works in C# 4.0 VS 2010.
```csharp namespace ConsoleApplication1 { class Program {
static void Main(string[] args)
{
Console.WriteLine(test);
Console.WriteLine(test(b: 3));
Console.ReadLine();
}
public int test(int a = 1, int b = 2)
{
return a + b;
}
}
}```