Is VB.NET the only .NET language that can handle default (C++) or optional (VB) arguments?  It doesn’t appear that C# can, unless I’m missing something, and although MS C++ does support default arguments, it does not support them for member functions of a managed type.

 

So…if I want to create a .NET class that has a member function with default arguments,  how do I do so?

 

I ask, because I’m trying to implement parts of Microsoft.VisualBasic.dll, and I’m working on the Collection class.  It’s Add member is defined as follows (VB.NET Syntax):

 

Public Sub Add( _
   ByVal Item As Object, _
   Optional ByVal Key As String, _
   Optional ByVal Before | After } As Object = Nothing _

)

 

 

I could implement it in either C# or C++ with overloaded methods, which would accomplish the same thing, but wouldn’t BE the same thing.  I could implement this in VB.NET if necessary, but I’d like to avoid that.

 

Any thoughts?

 

                                    -chris

 

Chris J. Breisch, MCSD, MCDBA

 

 

Reply via email to