Click here to Skip to main content
15,911,039 members
Home / Discussions / C#
   

C#

 
AnswerRe: Saving changes to a dataGridView - colour rows Pin
joon vh.28-Mar-07 4:08
joon vh.28-Mar-07 4:08 
QuestionIs is possible to Serialise a Dynamically created assembly? Pin
Trevor T27-Mar-07 11:07
Trevor T27-Mar-07 11:07 
Questionread image from picture box Pin
iman_kh27-Mar-07 10:53
iman_kh27-Mar-07 10:53 
AnswerRe: read image from picture box Pin
art_coding27-Mar-07 11:37
art_coding27-Mar-07 11:37 
QuestionAcceptchange() in data set Pin
iman_kh27-Mar-07 10:51
iman_kh27-Mar-07 10:51 
QuestionProvider model Pin
netJP12L27-Mar-07 10:24
netJP12L27-Mar-07 10:24 
QuestionC# network transfer stream problem Pin
art_coding27-Mar-07 10:19
art_coding27-Mar-07 10:19 
QuestionClass "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 9:54
Edmundisme27-Mar-07 9:54 
OK, I have a class "Dog" with methods play() and Euthanize(). I have a class Child that must be able to "Play" with "Dog", but not "Euthanize" it. I have a class "Vet" that must be able to "Euthanize" "Dog".

I do not want to isolate "Dog" and "Vet" in their own assembly and make "Euthanize" an internal method of "Dog". I also don't want to nest Dog in Vet.

So, How can I enforce these relationships. I do not trust the child to not play vet and "Euthanize" dog, so it must be IMPOSSIBLE for the Child to call "Euthanize" on "Dog".

I don't know if simply giving the child an IPlayable iterface and the Vet an IEuthanizable interface will be restrictive enough as Child could cast IPlayable to Dog and thereby access its "Euthanize" method.

You used to be able to accomplish this with "Friend" classes in C++. There are no friend classes in C#. Am I forced to either put "Vet" and "Dog" in the same assembly and make Dog.Euthanize internal or to nest "Dog" in "Vet" (which doesn't make sense from an object-oriented standpoint because I want classes "Pound" and "PetStore" to be able to create "Dog" objects without any knowledge of the "Vet" class).

Any ideas?

Thanks!

Ian
AnswerRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Dave Kreskowiak27-Mar-07 10:11
mveDave Kreskowiak27-Mar-07 10:11 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Austin Harris27-Mar-07 10:25
Austin Harris27-Mar-07 10:25 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Dave Kreskowiak27-Mar-07 12:43
mveDave Kreskowiak27-Mar-07 12:43 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:26
Leslie Sanford27-Mar-07 10:26 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 10:27
Edmundisme27-Mar-07 10:27 
AnswerRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:22
Leslie Sanford27-Mar-07 10:22 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 10:36
Edmundisme27-Mar-07 10:36 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Leslie Sanford27-Mar-07 10:47
Leslie Sanford27-Mar-07 10:47 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme27-Mar-07 11:49
Edmundisme27-Mar-07 11:49 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
led mike28-Mar-07 5:21
led mike28-Mar-07 5:21 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 6:15
Edmundisme28-Mar-07 6:15 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 6:30
Edmundisme28-Mar-07 6:30 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
led mike28-Mar-07 6:52
led mike28-Mar-07 6:52 
GeneralRe: Class "Child" MUST NOT call "Euthanize" on class "Dog" Pin
Edmundisme28-Mar-07 7:21
Edmundisme28-Mar-07 7:21 
QuestionAppDomains & Loading Assemblies Pin
AJ12327-Mar-07 9:19
AJ12327-Mar-07 9:19 
AnswerRe: AppDomains & Loading Assemblies Pin
S. Senthil Kumar27-Mar-07 17:01
S. Senthil Kumar27-Mar-07 17:01 
Questionchange hue saturation Pin
samreengr827-Mar-07 9:03
samreengr827-Mar-07 9:03 

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.