C
C
CityzenUNDEAD2020-06-13 20:28:03
C++ / C#
CityzenUNDEAD, 2020-06-13 20:28:03

Where does the entry occur when a method is called?

Hello everyone!
There is this code

class MyClass
    {
        private string field = null;

        public void SetField(string value) 
        {
            field = value;
        }

        public string GetField() 
        {
            return field;
        } 

    }
    class Program
    {
        static void Main(string[] args)
        {
            MyClass inctance = new MyClass();

            Console.WriteLine(inctance.GetField());

            inctance.SetField("C вертушки!");

            Console.WriteLine(inctance.GetField());

            Console.ReadKey();
        }
    }


Where in the end the value is written by this method inctance.SetField("C turntables!");
Does it write to the class itself or only to the class instance that is in the inctance variable?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Demidko, 2020-06-13
@CityzenUNDEAD

"only to the instance of the class that is in the inctance variable" -- right.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question