oop - Designing classes in C# -


I know this should be a general question, but take a look:

I have a The test is class:

  public class EmployeeClass {Private Int _id; Private string _name; Private double _ salaris; Public Entry ID {{}} {{}} set {...}} public string name {get} {{}} set {...}} // and so on} {/ code>  

The question is: For me, it is not able to understand the public properties that match all the private areas.

What is the approach to limiting access to the class intents?

At the time of initialization, I reach the field directly, like:

  public employee class (int id, string name, double pay) {_id = id; _name = name; _salary = Pay; }  

And do everything (at least those who have some kind of irreversibleness) read only?

What's the best way here?

Thank you for your opinion

There are several approaches, two of them in class In general, (and this is only a small taste):

  • On many public-setters classes


    Comments

    Popular posts from this blog

    asp.net - Javascript/DOM Why is does my form not support submit()? -

    sockets - Delphi: TTcpServer, connection reset when reading -

    javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -