How to identify an object and establish a connection between them [C #]

What is the best way to identify objects and their relationship between them? Since I'm new to programming [C # windows application], it's hard for me to create relationships between objects. Can someone suggest me a better way to get started?

Thank you Kartik

+3
source share
2 answers

You should probably become familiar with object-oriented programming and design. Then read on C # programming.

Here are some tips for the book:

Then, when you are ready, you can go to Jon Skeet book =)

, . - .

+4

:

, . , , , , , .

, , .

  • StaffMember

c# classes properties , :

class StaffMember
{
    public string Name { get; set; }
    public string Address { get; set; }
    public DateTime DateStarted { get; set; }
    public Department Department { get; set; }    // class Department
}

class Department
{
    public string Name { get; set; }
    public Position Position { get; set; }    // class Position
}

class Position
{
    public string Title { get; set; }
    public string PrimaryRole { get; set; }
}

:

static void Main()
{
    StaffMember employee = new StaffMember();
    employee.Name = "Ali Gray";
    employee.Address = "123 Abc Street";
    employee.DateStarted = DateTime.Now;

    // Now add the employees department
    employee.Department = new Department();
    employee.Department.Name = "Checkout";

    // Now add the employees position
    employee.Department.Position = new Position();
    employee.Department.Position.Title = "Bag Packer";
    employee.Department.Position.PrimaryRole = "Pack bags";
}

, , , , oo design.

+2

All Articles