M
M
Maria2018-02-21 19:11:31
C++ / C#
Maria, 2018-02-21 19:11:31

Why can't a new value be assigned to a variable in a class?

Good afternoon! Faced with the fact that it is impossible to assign a new value to a variable directly in the class, and not in the method. Please tell me why...5a8d9a2fdbfb1508415229.jpeg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Peter, 2018-02-21
@missbells

You have already initialized the variable with a value once, outside the method, as far as I know, you cannot change the variable. In the body of the method, you can assign a new one. Not within the class.

D
Denis Zagaevsky, 2018-02-21
@zagayevskiy

Because code cannot be written inside a class outside of methods and initialization sections.

E
eRKa, 2018-02-21
@kttotto

Because the syntax of the C# language does not allow it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question