Is state another name for field or is it something different?

For example:

private int telNumber;

can I say about telNumber that it is a state or it is a field?

closed as unclear what you're asking by user40980, user7043, EL Yusubov, gnat, Reactgular Aug 27 '13 at 8:35

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    it's a field that holds some state about the object it is in – ratchet freak Aug 23 '13 at 16:04
  • What is a state? – kush Aug 23 '13 at 16:06

Let's say I have the following class:

public class Foo
    private int _bar;
    private string _baz;

    public Foo(int bar, string baz)
        _bar = bar;
        _baz = baz;

    public void ChangeBar(int newBar)
        _bar = newBar;

I can create an instance of the class like this:

var myFoo = new Foo(3, "Qux");

The values for _bar and _baz collectively form myFoo's state.

If I change _bar, like this:


That means that the state of myFoo has changed, because one or more of the fields has changed.

  • so you mean that the field is the name of the holder for the value and the value itself is the state?? – Lamaasi Aug 23 '13 at 16:19
  • 1
    Yes, but the value of _bar is the state of _bar. The value of both _bar and _baz are the state of myFoo. Get it? :) Otherwise, you could just say "the value of myFoo," which is not really accurate, because myFoo is an object, not a primitive like a number. – Robert Harvey Aug 23 '13 at 16:25

In layman's words:

  • No. State is not another name for a field.
  • The state of an object is the combination of the values of all its fields.
  • If any field gets changed, it is said that the object's state (as a whole) has changed.

State is more of a usage pattern than a particular way to define a class's properties. I would only consider a variable part of the State when, according to DoFactory,


Allow[s] an object to alter its behavior when its internal state changes. The object will appear to change its class.

  • You use the term "state" in it's own definition. That's a pretty big no-no. – Servy Aug 23 '13 at 19:23
  • 1
    I'm not really familiar with the site at all. If you would like to make such a proposal that would be fine. Being an active member of this community, I'm really only concerned with the content here. This particular answer isn't a good answer, since you're using the term you're defining, when defining it, which makes for a rather poor definition. Consider finding a different source for a definition, if you want to cite another definition. Personally, I'm satisfied with the other answers to this question so I don't see the need. – Servy Aug 23 '13 at 19:32
  • so you you want to define state as the combination of field inside? My answer is the same, that the real meaning of state can only be established with supporting infrastructure that demonstrates how the variable create a Stateful behavior pattern. – Andyz Smith Aug 23 '13 at 19:33
  • It's kind of like 'what is a nail'. If you say a nail is a longitudinal piece of metal with a sharpened point and a flattened end, nobody is going to have any idea what you talking about. But watch somebody using a hammer and nail, they immediately understand the definition of nail. – Andyz Smith Aug 23 '13 at 19:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.