-2

I have a class defined as follows:

class Foo
    {
        internal string IString;
        internal static string IstaticString;
        public Foo()
        {
            IstaticString = "static";
            IString = "non - static";
        }
    }

I am creating its instance in the main function as the following, in this caseIString is accessible through the object, whereas IstaticString is not accessible. Can anyone explain the reason for this?

enter image description here

cokeman19
  • 2,405
  • 1
  • 25
  • 40
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88

2 Answers2

2

static members are not accessible from instances. Foo.IstaticString should work

ASh
  • 34,632
  • 9
  • 60
  • 82
0

Static fields accessible from type not from instance. This Foo.IstaticString should work