Answer the question
In order to leave comments, you need to log in
Are properties (auto-properties) in c# the behavior or state of an object?
Actually, the question is: properties (auto-properties) in c # is the behavior or state of the object?
Answer the question
In order to leave comments, you need to log in
Let's define terminology:
I emphasize again, the object . Not a type, not a class (a class only describes the future object), but an object .
Behavior is how an object acts and reacts; behavior is expressed in terms of object state and message passing. In other words, the behavior of an object is its observable and externally verifiable
activity . ( Gradi Butch )
public sealed class Employee
{
private String m_Name; // Это состояние
private Int32 m_Age; // Это состояние
public String GetName() // Это поведение
{
return(m_Name);
}
public void SetName(String value) // Это поведение
{
m_Name = value;
}
public sealed class Employee
{
private String m_Name; // Это состояние
private Int32 m_Age; // Это состояние
public String Name // Это поведение
{
get { return(m_Name); }
set { m_Name = value; }
}
}
public abstract String GetName();
public abstract void SetName(String value);
This is the state of the object. These are the same getters and setters, that is, getters and setters are created during compilation. This is a kind of syntactic sugar.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question