Answer the question
In order to leave comments, you need to log in
How to work with class variables?
Good afternoon, the question arose, how to work with class variables?
Let's say we have this code:
using System;
class A
{
private int Variant;
public int Pr {
set { Variant = value; }
get { return Variant; } }
class B
{
private A Varaint2;
}
Answer the question
In order to leave comments, you need to log in
Em. just read about class constructors. everything should become clear.
find out that there is a default
one and you can create
Varaint2 = new A();
and many other useful things))
Update.
just in case, I’ll add it. suddenly ...
just for understanding, it would be nice to learn that classes are just a description / structure / classification)) I don’t know how to call it more correctly.
you work with class objects. create an instance of a class (a link to it), or get a link to an existing one.
And already at the link, fields, methods, etc. are available to you.))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question