Implementing a UML association

P

Paolo

I have 3 classes - their associations are modelled in UML thus:

Class A: 1 --> 1..* Class B: 1 --> 1..* Class C

How would I implement this in C#?

Thanks
 
A

Arne Vajhøj

Paolo said:
I have 3 classes - their associations are modelled in UML thus:

Class A: 1 --> 1..* Class B: 1 --> 1..* Class C

How would I implement this in C#?

Let A contain a List<B> and B contain a List<C>.

And make the code enforce minimum of 1 element,
if that is really important.

Arne
 
P

Paolo

Arne: thank you for the reply. I am new to C# so sorry if this next question
is a bit basic. When I create an instance of Class A I would create a
List<class B> as part of the instantiation. As I create a number of instances
of class B in my application presumably I then have to Add them to the
List<class B> in the class A object?
 
A

Arne Vajhøj

Paolo said:
I am new to C# so sorry if this next question
is a bit basic. When I create an instance of Class A I would create a
List<class B> as part of the instantiation. As I create a number of instances
of class B in my application presumably I then have to Add them to the
List<class B> in the class A object?

The list should be private, so either the B's should be created and
added inside A or something outside A should create them and
call a method in A that does the add.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top