Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using This in a method call
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00721707
Message ID:
00722875
Views:
11
For C#, I recommend the following book:

C# Design Patterns : A Tutorial
Author: James William Cooper


>Cathi,
>
>Do you have any good references for me getting up to speed on patterns? I have been looking for the last day or 2. I have been to the Patterns Home Page. But could be on the lookout for other good sites.
>
>Thanks,
>
>Perry
>
>>Perry,
>>
>>Using polymorphism can create very rich applications by implimenting the Abstract Factory Pattern. This allows for dynamic assembly loading. This pattern also allows you to obtain an object matching a particular interface, but only choose which specific class to instantiate at runtime. The advantage is flexibility. You can design an architecture that can easily be expanded and extended without redevelopment, and in some cases can be added on the fly without recompiling the original source code.
>>
>>>Thanks. I kind of figured it out right before I saw your reply. It appears that there are several things you can do in C# that would make your program difficult, if not impossible, to follow.
>>>
>>>I've been reading the chapter on polymorpism, and they have a lengthy discussion on assigning a derived class reference to a base class reference. I would think this type of programming would make it potentially very difficult to follow the method calls. They don't really give any concrete examples of why this would be a good practice.
>>>
>>>>What is actually going on is the writeline method is calling the ToString method of the class. If you look at the online help, you will see how it references the implicit call to ToString. This is confusing and for readability, I would recommend expicitly calling ToString.
>>>>
>>>>>I have been learning C# thru Deitel's C# book. They have an example that they don't clearly explain the reason for the result.
>>>>>
>>>>>In a contructor for a class they have:
>>>>>
>>>>>writeline("Circle 5 constructor: {0}", this );
>>>>>
>>>>>
>>>>>They explain that "this" implicitly calls the ToString() method of the class. How does the class know that ToString() is the method to call. There are 3 methods in the class. In looking at it, only one class returns a string. Could that be the reason?
>>>>>
>>>>>Thanks,
>>>>>
>>>>>Perry
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform