Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Accessing overloaded constructors
Message
 
To
13/09/2004 15:48:47
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00941066
Message ID:
00942153
Views:
26
Hmmm... maybe that's because I mainly have been using chaining with static constructors. I don't think I've ever used :this()...

Oh well, live and learn <g>...

+++ Rick ---

>Rick,
>
>Nope back at ya <g> ... that was the problem that Rex first posted about. You get an error if you use base:
>
>public class MyControl : UserControl
>{
>    private TextBox MyTextBox;
>    // and other control declarations
>
>    public MyControl()
>    {
>        InitializeComponent();
>    }
>
>    public MyControl(string InitString):base()
>    {
>        this.MyTextBox.Text = InitString;
>    }
>
>    // etc.etc.etc.
>}
>
>Change the :base() to :this() and it works fine (and it makes sense if you think about it) ... I wonder if you were thinking about some other scenario?
>
>~~Bonnie
>
>>Nope. It's:
>>
>>
public MyClass(int x, int y):base()
>>
>>
>>>Neil,
>>>
>>>Oh yeah, I forgot about that.
>>>
>>>public MyClass(int x, int y):this()
>>>{
>>>    // code here
>>>}
>>>
>>>Thanks for reminding me. =)
>>>
>>>~~Bonnie
>>>
>>>>Rex,
>>>>
>>>>This is known as constructor chaining and involves the use of this. A good example of chaining and most constructor related issues can be found at the following site.
>>>>
>>>>http://www.c-sharpcorner.com/Language/ConsNDestructorsInCSRVS.asp
>>>>
>>>>regards
>>>>Neil
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform