Search the web
Sign In
New User? Sign Up
CSharpDotNetGreek · C Sharp and dotNet Greek
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
contructor overload ref/eDN8053035157   Message List  
Reply | Forward Message #29 of 41 |
Re: [CSharpDotNetGreek] contructor overload ref/eDN8053035157

O/H dennis έγραψε:
>
>
> Hello guys!!!
>
>
>
> namespace ConsoleApplication3
>
> {
>
> class Program
>
> {
>
>
>
> public Program(string[] args) { Console.WriteLine("this is the
> constructor: {0}", args[0]); }
>
> public Program(string anarg) : this(anarg) { }
>
> }
>
> }
>


Διονύση

η γραμμή
public Program(string anarg) : this(anarg) { }
δεν είναι σωστή

η this(anarg) πάει να περάσει ένα string
στον άλλο κονστράκτορα
ο οποίος όμως περιμένει
array of string

Αρα, το σωστό είναι να φτιάξεις ένα
array, on the fly, και να του βάλεις
ως μοναδικό στοιχείο την παράμετρο που θες.
Δηλαδή

public Prog(string anarg) : this( new string[] { anarg }) {}

Δες προσεκτικά την νέα παράμετρο.
Αντί this(anarg)
γίνεται this( new string[] { anarg })

Θόδωρος

--
Regards
Theo

------------------------
Theo Bebekis
Thessaloniki, Greece
------------------------
Greek_Delphi_Prog : a Delphi Programming mailing list in Greek at
http://groups.yahoo.com/group/Greek_Delphi_Prog

CSharpDotNetGreek : A C# and .Net mailing list in Greek language at
http://groups.yahoo.com/group/CSharpDotNetGreek

atla_custom : a Unisoft Atlantis Customization mailing list at
http://groups.yahoo.com/group/atla_custom
------------------------



Tue Mar 18, 2008 9:28 am

bebekis
Offline Offline
Send Email Send Email

Forward
Message #29 of 41 |
Expand Messages Author Sort by Date

Hello guys!!! namespace ConsoleApplication3 { class Program { public Program(string[] args) { Console.WriteLine("this is the constructor: {0}", args[0]); } ...
dennis
fdennis090
Offline Send Email
Mar 18, 2008
9:17 am

... Διονύση η γραμμή public Program(string anarg) : this(anarg) { } δεν είναι σωστή η this(anarg) πάει να περάσει...
Theodoros Bebekis
bebekis
Offline Send Email
Mar 18, 2008
9:28 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help