[Mono-list] Constructors in C#

Joe Audette joe_audette@yahoo.com
Fri, 19 Nov 2004 11:08:46 -0800 (PST)


--0-1278980226-1100891326=:95206
Content-Type: text/plain; charset=us-ascii

ok,
 
How about this:
 
public class MyClass
{
 private string member;
 public MyClass ()
 {
  DoStuff("stuff");
 }
 public MyClass (String s)
 {
  DoStuff(s);
 }
 
 private void DoStuff(string s)
 {
  this.member = s;
 
 }
}
 
Joe


Brice Carpentier <brice@daknet.org> wrote:
Joe Audette wrote:
> The java example should work as is in C#
> 
well, doing this way, I get error CS0119 : "Expression denotes a 
`variable' where a `method group' was expected"

Regards,
-- 
Brice Carpentier aka Br|ce
_______________________________________________
Mono-list maillist - Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list


joe_audette@yahoo.com
http://www.joeaudette.com
http://www.mojoportal.com
--0-1278980226-1100891326=:95206
Content-Type: text/html; charset=us-ascii

<DIV>ok,</DIV>
<DIV>&nbsp;</DIV>
<DIV>How about this:</DIV>
<DIV>&nbsp;</DIV>
<DIV>public class MyClass<BR>{<BR>&nbsp;private string member;</DIV>
<DIV>&nbsp;public MyClass ()<BR>&nbsp;{<BR>&nbsp;&nbsp;DoStuff("stuff");<BR>&nbsp;}</DIV>
<DIV>&nbsp;public MyClass (String s)<BR>&nbsp;{<BR>&nbsp;&nbsp;DoStuff(s);<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;private void DoStuff(string s)<BR>&nbsp;{<BR>&nbsp;&nbsp;this.member = s;<BR>&nbsp;<BR>&nbsp;}<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>Joe<BR><BR><BR><B><I>Brice Carpentier &lt;brice@daknet.org&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Joe Audette wrote:<BR>&gt; The java example should work as is in C#<BR>&gt; <BR>well, doing this way, I get error CS0119 : "Expression denotes a <BR>`variable' where a `method group' was expected"<BR><BR>Regards,<BR>-- <BR>Brice Carpentier aka Br|ce<BR>_______________________________________________<BR>Mono-list maillist - Mono-list@lists.ximian.com<BR>http://lists.ximian.com/mailman/listinfo/mono-list<BR></BLOCKQUOTE><BR><BR>joe_audette@yahoo.com<br>http://www.joeaudette.com<br>http://www.mojoportal.com
--0-1278980226-1100891326=:95206--