Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Ok, what I want to do is have a "telephone" struct in a DLL where the list of telephone is accessible not the struct its self. Basically I have some demographic data in the class and within there can be multiple numbers/types/statuses thus the list of telephone data. I keep getting Inconsistent accessibility unless I make it public which I don't want to do.
--- Addition ---
Please see below for further clarification. However short version, trying to figure out the best practice for accessing/updating the information in the DLL while maintaining a certain level of control over what is available to the calling application.
Posted
Updated 20-Mar-14 5:45am
v2
Comments
Richard MacCutchan 20-Mar-14 8:50am    
OK, and what exactly are you asking for?
Maarten Kools 20-Mar-14 9:07am    
You either expose the whole thing, or you don't. If you wish to keep the struct "telephone" private, you cannot expose a public list of it either, makes sense, doesn't it?
MacRaider4 20-Mar-14 9:11am    
yeah, that's what I thought...
MacRaider4 20-Mar-14 9:14am    
I was over thinking it, hate when that happens... thanks guys!
Sergey Alexandrovich Kryukov 20-Mar-14 11:25am    
First of all, you accepted the "answer" which cannot help you in principle. Please see my comments to Solution 1.
Idea with interface is fruitful, but the answer does not provide any solutions, besides, solutions can be different. Interface approach is totally irrelevant to you access problem.

Do you really think your problem is solved? :-)

If not, write some code sample which reproduces the problem. Make sure the sample is minimal. And read about access specifiers.

—SA

1 solution

1.First you should have a class named Telephone and not a struct and this class should implement an interface let named TelephoneInfo.
2.In the TelephoneInfo interface (that must be public) you have to add all properties and methods that you want to be accessible from the outside world.
3.Your list of Telephone should be changed to list of TelephoneInfo.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 20-Mar-14 11:23am    
Sorry, I voted 1. Who told you that OP needs a class, not struct? It could be anything. Perhaps you think that interface can only be implemented by a class? Wrong. You totally failed to address access aspect. Naive OP accepted the answer, but it is totally wrong.
—SA
Raul Iloc 20-Mar-14 13:27pm    
What is wrong with you gay!?
I gave a solution that I considered to be the best for this question. I know very well that also struct could be used to implement an interface, but is not indicated to be used strcut in this case, like also MSDN said: http://msdn.microsoft.com/en-us/library/ms229017(v=vs.110).aspx
Sergey Alexandrovich Kryukov 20-Mar-14 13:42pm    
Okay, I got it. You "consider"... Don't you think this is not enough? :-).
--SA
Raul Iloc 20-Mar-14 13:31pm    
In the meantime, the initial question was changed/updated with other info, but my answer was for the original question!
Sergey Alexandrovich Kryukov 20-Mar-14 13:43pm    
I can understand that, such things happen. I would advice to correct your answer accordingly or add a note to it. It can be very helpful.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900