Click here to Skip to main content
15,888,037 members
Home / Discussions / C#
   

C#

 
GeneralRe: Control Designer & Child Controls Issue Pin
Heath Stewart24-Sep-03 8:50
protectorHeath Stewart24-Sep-03 8:50 
GeneralRe: Control Designer & Child Controls Issue Pin
scott@otech.com24-Sep-03 9:02
scott@otech.com24-Sep-03 9:02 
Questioncopy constructor needed? Pin
berndg23-Sep-03 2:59
berndg23-Sep-03 2:59 
AnswerRe: copy constructor needed? Pin
Heath Stewart23-Sep-03 3:12
protectorHeath Stewart23-Sep-03 3:12 
GeneralRe: copy constructor needed? Pin
Alvaro Mendez23-Sep-03 4:43
Alvaro Mendez23-Sep-03 4:43 
GeneralRe: copy constructor needed? Pin
Heath Stewart23-Sep-03 5:39
protectorHeath Stewart23-Sep-03 5:39 
GeneralRe: copy constructor needed? Pin
Alvaro Mendez23-Sep-03 10:37
Alvaro Mendez23-Sep-03 10:37 
GeneralRe: copy constructor needed? Pin
Heath Stewart23-Sep-03 10:47
protectorHeath Stewart23-Sep-03 10:47 
First of all, I always type the implicit this. to help distinguish what's an instance member and what's a variable, just like I type the class name even for static members. It's basically just a way I manage my code. It makes absolutely NO difference when it compiles. The IL instructions are the same in either case.

Second, the seemingly self-recursive cloning: doesn't happen. Are you familiar with explicit interface implementations? Notice how I used the interface name in the last Clone method: object ICloneable.Clone()? That means that you must cast the object (or define the object reference as that interface) in order to call that particular method. In the explicit interface implementation, I called this.Clone(); which is the Clone method of my class. If I did ((ICloneable)this).Clone(), then that would definitely be a problem! That is not what I did, however. Trust me, it works.

Try throwing together a quick class that does this. Compile it and examine the IL (don't decompile - the IL is what you want to look at for this): it should show you what's being done.

You don't necessarily have to implement ICloneable as an explicit interface. I only did it because someone (might have been you - don't remember) complained that you have to cast the return value of Clone. By having another Clone method on your class that returns the proper type, you won't have to worry about it. Heck, you don't even need to implement ICloneable, but that may throw-off developers that are thinking that you implement ICloneable when, in fact, you don't (and they didn't read your documentation, which happens far too often than not).

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralRe: copy constructor needed? Pin
Alvaro Mendez23-Sep-03 11:01
Alvaro Mendez23-Sep-03 11:01 
GeneralRe: copy constructor needed? Pin
Heath Stewart23-Sep-03 13:04
protectorHeath Stewart23-Sep-03 13:04 
GeneralWebservice over SSL with multiple servers Pin
solidstore23-Sep-03 1:14
solidstore23-Sep-03 1:14 
GeneralRe: Webservice over SSL with multiple servers Pin
Heath Stewart23-Sep-03 3:25
protectorHeath Stewart23-Sep-03 3:25 
GeneralRe: Webservice over SSL with multiple servers Pin
solidstore23-Sep-03 3:54
solidstore23-Sep-03 3:54 
GeneralRe: Webservice over SSL with multiple servers Pin
Heath Stewart23-Sep-03 4:34
protectorHeath Stewart23-Sep-03 4:34 
GeneralRe: Webservice over SSL with multiple servers Pin
Heath Stewart23-Sep-03 4:36
protectorHeath Stewart23-Sep-03 4:36 
GeneralNamed Mutex (I think) Pin
James Simpson23-Sep-03 0:52
James Simpson23-Sep-03 0:52 
GeneralRe: Named Mutex (I think) Pin
Heath Stewart23-Sep-03 3:31
protectorHeath Stewart23-Sep-03 3:31 
GeneralRe: Named Mutex (I think) Pin
Blake Coverett23-Sep-03 6:14
Blake Coverett23-Sep-03 6:14 
Generalaspnet_wp.exe restarting unexpectedly Pin
solidstore22-Sep-03 23:52
solidstore22-Sep-03 23:52 
GeneralOutlook Automation and sending Bulk E-mail Pin
Braulio Dez22-Sep-03 23:44
Braulio Dez22-Sep-03 23:44 
GeneralTheoretical Question on object creation Pin
Rohde22-Sep-03 23:09
Rohde22-Sep-03 23:09 
GeneralRe: Theoretical Question on object creation Pin
shaunAustin22-Sep-03 23:16
shaunAustin22-Sep-03 23:16 
GeneralRe: Theoretical Question on object creation Pin
Rohde22-Sep-03 23:30
Rohde22-Sep-03 23:30 
GeneralRe: Theoretical Question on object creation Pin
Blake Coverett22-Sep-03 23:32
Blake Coverett22-Sep-03 23:32 
GeneralRe: Theoretical Question on object creation Pin
Blake Coverett22-Sep-03 23:30
Blake Coverett22-Sep-03 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.