S
S
Shameless192020-12-17 15:03:03
C++ / C#
Shameless19, 2020-12-17 15:03:03

Individual value for each object when inheriting?

The script inherits variables (let's say B and C). The value B is common for all objects, and C is individual for each object on which the script hangs. How to describe C so that each object is assigned a different meaning , depending on the circumstances accompanying it personally?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-12-17
@Shameless19

Something like this

class A
{
  public virtual int C
  {
    get => 12;    
  }
}

class B :  A
{
  public override int C 
  {
     get => 11;    
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question