L
L
Lackym2019-07-23 20:20:56
OOP
Lackym, 2019-07-23 20:20:56

C# is it possible to pass to base a value created in a constructor?

public MyClass(int a, int b) : base(a, b, c)
    {
      c = a + b; //Получаю значение C в конструкторе и строго после это хочу передать его в base
    }

Is it even possible?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Proskurin, 2019-07-23
@Lackym

It's better to create a method that will create a value for c, and shove its call as the third argument to base without cluttering up the constructor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question