Optional arguments

  • Thread starter Thread starter Jens Thiel
  • Start date Start date
J

Jens Thiel

Hi all, I would like to exactly mimic the following VB.NET interface

Public Shared Function Fun( _
Optional ByVal p As Integer = 10 _
) As Double()

in C#. I already use OptionalAttribute from System.Runtime.InteropServices.
I tried to combine it with DefaultValueAttribute from System.ComponentModel
but the result is not the same. How do I set the default value in the same
way VB.NET does?

(I do not want to overload or discuss overloads ./. optional parameters ;-)
 
----- Jens Thiel wrote: ----

Hi all, I would like to exactly mimic the following VB.NET interfac

Public Shared Function Fun(
Optional ByVal p As Integer = 10
) As Double(

in C#. I already use OptionalAttribute from System.Runtime.InteropServices
I tried to combine it with DefaultValueAttribute from System.ComponentMode
but the result is not the same. How do I set the default value in the sam
way VB.NET does
(I do not want to overload or discuss overloads ./. optional parameters ;-

in that case, that's easy. :) you can't
 
Back
Top