Good day!

There is a code, please tell me what technology of the C # language should I use and how it is called, in order to implement the process of assigning the enum variable when calling the Summ() function of the Summ() class

 enum AnyEnum { FIRST_VALUE, SECOND_VALUE } internal class AnyClass { int a = 0; internal void Summ(AnyEnum enum) { if(enum == AnyEnum.FIRST_VALUE) a = 5; else if(enum == AnyEnum.SECOND_VALUE) a = 10; } } internal class MainClass { int f = 0; public MainClass(int f) { this.f = f; AnyEnum enum = AnyEnum.FIRST_VALUE; if(this.f > 5) enum = AnyEnum.SECOND_VALUE; AnyClass anyClass = new AnyClass(); anyClass.Summ(enum); } } 
  • one
    anyClass.Summ((this.f > 5)? AnyEnum.SECOND_VALUE : AnyEnum.FIRST_VALUE); - ternary operator - Igor
  • The purpose is not clear. There are delegates, in a pinch, there are "pointers", or there are procedure tokens. - nick_n_a
  • @nick_n_a goal to reduce the record, learn a new principle in the language, if you have time to show how you would use the above listed .... I will be very grateful to you. - K.Oleg
  • one
    @ K.Oleg instead of several if you can use switch - null
  • one
    @ K.Oleg - anyClass.Summ((this.f < 5)? AnyEnum.FIRST_VALUE : ((this.f < 10)? AnyEnum.SECOND_VALUE : AnyEnum.THIRD_VALUE)); - Igor

0