[Mono-list] Default Arguments
Chris J. Breisch
cjbreisch@altavista.net
Fri, 3 May 2002 09:23:13 -0500
This is a multi-part message in MIME format.
------=_NextPart_000_0000_01C1F284.2D4A6660
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
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
------=_NextPart_000_0000_01C1F284.2D4A6660
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html>
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:9.0pt;
font-family:Verdana;}
h1
{margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
text-align:center;
page-break-after:avoid;
font-size:16.0pt;
font-family:Arial;}
h2
{margin-top:12.0pt;
margin-right:0in;
margin-bottom:3.0pt;
margin-left:0in;
page-break-after:avoid;
font-size:14.0pt;
font-family:Arial;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
pre
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.Code, li.Code, div.Code
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.E-mail, li.E-mail, div.E-mail
{margin:0in;
margin-bottom:.0001pt;
text-autospace:none;
font-size:9.0pt;
font-family:Verdana;
color:maroon;}
span.NormalFont
{font-family:Verdana;}
p.code0, li.code0, div.code0
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
p.e-mail0, li.e-mail0, div.e-mail0
{margin:0in;
margin-bottom:.0001pt;
text-autospace:none;
font-size:9.0pt;
font-family:Verdana;
color:maroon;}
span.normalfont0
{font-family:Verdana;}
span.emailstyle20
{font-family:Verdana;
color:maroon;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
span.EmailStyle25
{font-family:Verdana;
color:maroon;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DSection1>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'>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.</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'>So…if I want to create a =
.NET class
that has a member function with default arguments, how do I do =
so?</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'>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):</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<pre><b><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;
font-weight:bold'>Public Sub Add( _</span></font></b></pre><pre><b><font
size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-weight:bold'> ByVal =
</span></font></b><i><span
style=3D'font-style:italic'><a href=3D"" =
onclick=3D"showTip(this)">Item</a></span></i><b><span
style=3D'font-weight:bold'> As Object, _</span></b></pre><pre><b><font =
size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-weight:bold'> =
Optional ByVal </span></font></b><i><span
style=3D'font-style:italic'><a href=3D"" =
onclick=3D"showTip(this)">Key</a></span></i><b><span
style=3D'font-weight:bold'> As String, =
_</span></b></pre><pre><b><font
size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-weight:bold'> =
Optional ByVal </span></font></b>{ <i><span
style=3D'font-style:italic'><a href=3D"" =
onclick=3D"showTip(this)">Before</a> | <a
href=3D"" onclick=3D"showTip(this)">After</a></span></i> }<b><span
style=3D'font-weight:bold'> As Object =3D Nothing =
_</span></b></pre>
<p class=3DMsoNormal><b><font size=3D1 face=3DVerdana><span =
style=3D'font-size:9.0pt;
font-weight:bold'>)</span></font></b></p>
<p class=3DMsoNormal><b><font size=3D1 face=3DVerdana><span =
style=3D'font-size:9.0pt;
font-weight:bold'> </span></font></b></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'>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.</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'>Any thoughts?</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> &nbs=
p;  =
; =
-chris</span></font></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><b><font size=3D1 color=3Dmaroon =
face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon;font-weight:bold'>Chris J. =
Breisch, <i><span
style=3D'font-style:italic'>MCSD, MCDBA</span></i></span></font></b></p>
<p class=3DMsoNormal><font size=3D1 color=3Dmaroon face=3DVerdana><span
style=3D'font-size:9.0pt;color:maroon'> </span></font></p>
<p class=3DMsoNormal><font size=3D1 face=3DVerdana><span =
style=3D'font-size:9.0pt'> </span></font></p>
</div>
</body>
</html>
------=_NextPart_000_0000_01C1F284.2D4A6660--