Home All Groups Group Topic Archive Search About

Why does a private implementation of ICloneable work?

Author
10 Apr 2006 2:26 PM
cmay
Can someone explain why you can implement ICloneable with a private
function and it works?

e.g.

Imports System
Public Class BusinessObject
    Implements ICloneable

    Private Function privateClone() As Object Implements
ICloneable.Clone
        Dim MyClone As Object = makeClone()
        Return MyClone
    End Function

End Class

Does that fact that the Clone is public on ICloneable mean that the
"private" above is ignored when the object is being dealt with as type
ICloneable?

Author
10 Apr 2006 3:17 PM
Alvin Bruney - ASP.NET MVP
The modify tag, private, does not apply to the compiler. It is capable of
calling the method. The tag is applicable only to calling code.

--
Warm Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Professional VSTO 2005 - Wrox/Wiley 2006
Blog: http://msmvps.com/blogs/Alvin/
-------------------------------------------------------



Show quote
"cmay" <c***@walshgroup.com> wrote in message
news:1144679199.957344.262490@g10g2000cwb.googlegroups.com...
> Can someone explain why you can implement ICloneable with a private
> function and it works?
>
> e.g.
>
> Imports System
> Public Class BusinessObject
>     Implements ICloneable
>
>     Private Function privateClone() As Object Implements
> ICloneable.Clone
>         Dim MyClone As Object = makeClone()
>         Return MyClone
>     End Function
>
> End Class
>
> Does that fact that the Clone is public on ICloneable mean that the
> "private" above is ignored when the object is being dealt with as type
> ICloneable?
>
Author
10 Apr 2006 3:33 PM
Patrice
IMO  it is still called throught IClonable.Clone which is public and that in
turns call the private function.

Lutz Reflector should help to find out what goes on behind the scene :
http://www.aisto.com/roeder/dotnet/
--
Patrice

"cmay" <c***@walshgroup.com> a écrit dans le message de news:
1144679199.957344.262***@g10g2000cwb.googlegroups.com...
Show quote
> Can someone explain why you can implement ICloneable with a private
> function and it works?
>
> e.g.
>
> Imports System
> Public Class BusinessObject
>    Implements ICloneable
>
>    Private Function privateClone() As Object Implements
> ICloneable.Clone
>        Dim MyClone As Object = makeClone()
>        Return MyClone
>    End Function
>
> End Class
>
> Does that fact that the Clone is public on ICloneable mean that the
> "private" above is ignored when the object is being dealt with as type
> ICloneable?
>

AddThis Social Bookmark Button