Optional arguments

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 ;-)
 
G

Guest

----- 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top