Click here to Skip to main content
15,921,841 members
Home / Discussions / C#
   

C#

 
Generalnetwork path in conjunction with file.exists Pin
RB@Emphasys17-Jan-05 5:38
RB@Emphasys17-Jan-05 5:38 
GeneralRe: network path in conjunction with file.exists Pin
Heath Stewart17-Jan-05 6:28
protectorHeath Stewart17-Jan-05 6:28 
Generalinternal interfaces Pin
emission17-Jan-05 2:27
emission17-Jan-05 2:27 
GeneralRe: internal interfaces Pin
leppie17-Jan-05 4:36
leppie17-Jan-05 4:36 
GeneralRe: internal interfaces Pin
emission17-Jan-05 6:15
emission17-Jan-05 6:15 
GeneralRe: internal interfaces Pin
Heath Stewart17-Jan-05 6:41
protectorHeath Stewart17-Jan-05 6:41 
GeneralRe: internal interfaces Pin
emission17-Jan-05 10:02
emission17-Jan-05 10:02 
GeneralRe: internal interfaces Pin
Heath Stewart17-Jan-05 10:52
protectorHeath Stewart17-Jan-05 10:52 
emission wrote:
Is there no overhead when converting, i.e using ((IBaseObject)Dog).baseobject instead of directly accessing a public Dog.baseobject?

Negligable. A cast is an instruction that must be processed but compared to boxing operations these are trivial.

emission wrote:
However, this time it's more a design issue than a security issue, and I just curiously wonder about the reasons behind.

No one said that CAS has to be used only for security. Even the term "security" is rather loose. If security means that you don't want other developers via their assemblies to "see" or even access the member than CAS is what you want. Even with explicit interface implementations (i.e., what you're currently doing) a coder merely has to cast to the interface. Even if you used the BrowsableAttribute or EditorVisibilityAttribute you're only hiding it. The only way to truly deny access to the member is CAS.

In .NET 2.0 a new attribute - InternalsVisibleToAttribute[^] - allows compilers to compile code that accesses internal members from another assembly.

emission wrote:
internal int IAnimal.Age

That would be a voilation. Besides, when you compile this the member is actually private, much more strict than your internal access modifier. The thing is that your object must be cast to an interface object on which the member is truly called, which must be public. The interface object references your object, however, so your private member is not access directly.

You can learn more about implicit and explicit interfaces at http://msdn.microsoft.com/library/en-us/csspec/html/vclrfcsharpspec_13_4_1.asp[^] (C# Language Specification).

This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: internal interfaces Pin
emission17-Jan-05 12:30
emission17-Jan-05 12:30 
Generaldebugging diabled Pin
Member 166075017-Jan-05 2:25
Member 166075017-Jan-05 2:25 
GeneralRe: debugging diabled Pin
Heath Stewart17-Jan-05 7:11
protectorHeath Stewart17-Jan-05 7:11 
GeneralCreating ms installer with V. C# Pin
basbous17-Jan-05 2:13
basbous17-Jan-05 2:13 
GeneralRe: Creating ms installer with V. C# Pin
Heath Stewart17-Jan-05 6:46
protectorHeath Stewart17-Jan-05 6:46 
GeneralC# Pin
Anonymous17-Jan-05 2:10
Anonymous17-Jan-05 2:10 
GeneralRe: C# Pin
johnhebert17-Jan-05 4:42
johnhebert17-Jan-05 4:42 
GeneralListing a files in a client directory Pin
Sree7417-Jan-05 1:46
sussSree7417-Jan-05 1:46 
GeneralRe: Listing a files in a client directory Pin
Heath Stewart17-Jan-05 6:52
protectorHeath Stewart17-Jan-05 6:52 
GeneralRe: Listing a files in a client directory Pin
Member 37818918-Jan-05 4:04
Member 37818918-Jan-05 4:04 
GeneralReading local file on the client side Pin
Sreeanth17-Jan-05 1:37
sussSreeanth17-Jan-05 1:37 
GeneralRe: Reading local file on the client side Pin
leppie17-Jan-05 4:40
leppie17-Jan-05 4:40 
GeneralRe: Reading local file on the client side Pin
Heath Stewart17-Jan-05 7:02
protectorHeath Stewart17-Jan-05 7:02 
GeneralClient/Server Pin
Gregg Holter16-Jan-05 23:50
Gregg Holter16-Jan-05 23:50 
GeneralRe: Client/Server Pin
Robert Rohde17-Jan-05 0:10
Robert Rohde17-Jan-05 0:10 
GeneralRe: Client/Server Pin
Gregg Holter17-Jan-05 0:12
Gregg Holter17-Jan-05 0:12 
GeneralCommit Charge Pin
Alex Leshinsky16-Jan-05 22:43
Alex Leshinsky16-Jan-05 22:43 

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.