locked
Associative relationship between class RRS feed

  • Question

  • User1241685987 posted

    Hi,

    I want implementation association relationship with two classes.
    What i do?
    Can you give me one example?

    Sunday, October 19, 2014 4:55 PM

Answers

  • User1109032460 posted

    Here's a very short example of an associative class for you.

    public class Student
    {
      public ReadOnlyList<Enrollment> Enrollments { get; }
    }
    
    // This is the associative class in this example
    public class Enrollment
    {
      public decimal FinalGrade { get; }
      public ReadOnlyList<Grade> AssignmentGrades { get; }
      public class Class { get; }
    }
    
    public class Class
    {
      public string Name { get; }
      public string Code { get; }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 23, 2014 6:38 AM

All replies

  • User-434868552 posted

    @life24

    this seems to be a very open ended question.

    q.v.  http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer

    what kind of association?  in memory?  an SQL database?   inheritance (isA) -- a truck is a car?  components (a car has wheels, motor, ...)?  one-to-one?  one-to-many?  many-to-many?

    please clarify.

    Sunday, October 19, 2014 5:31 PM
  • User1241685987 posted

    Thank you for reply.

    In Software Engineering we have Associative Relationship. I want show this concept.But practical. For example with c++ or c# language.

    Sunday, October 19, 2014 5:58 PM
  • User-434868552 posted

    @life24    you are welcome.

    sorry, at least for me, you're still lacking in clarity ...

    In Software Engineering we have Associative Relationship

    Can you guess what Google returns as its first result for me?

    answer:  http://forums.asp.net/p/2013912/5795521.aspx?Re+Associative+relationship+between+class == your question in this thread.

    the other Google links are obtuse.

    again, at least for me, substantially more clarity is required.

    Did you read http://weblogs.asp.net/gerrylowry/clarity-is-important-both-in-question-and-in-answer ?

    I want show this concept

    Please be specific; please describe the concept that you wish to show.

    "Does your dog bite?" 

    Sunday, October 19, 2014 7:39 PM
  • User1109032460 posted

    Here's a very short example of an associative class for you.

    public class Student
    {
      public ReadOnlyList<Enrollment> Enrollments { get; }
    }
    
    // This is the associative class in this example
    public class Enrollment
    {
      public decimal FinalGrade { get; }
      public ReadOnlyList<Grade> AssignmentGrades { get; }
      public class Class { get; }
    }
    
    public class Class
    {
      public string Name { get; }
      public string Code { get; }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 23, 2014 6:38 AM