Explain, please, what is this property of the field?

void ButtonState(bool state) { button_ClearPT.Enabled = state; button_Encrypt.Enabled = state; button_Decrypt.Enabled = state; } 

I asked Google, but he is silent or I'm not looking there. The property control.enabled judging by the msdn, can take two values ​​only true or false, but what is a state ?

  • 2
    This means that the buttons will be active or not active, depending on the value of the state input parameter that is passed to the method. - Atlantis
  • state is a parameter of your method that has a bool type and accepts these two values - DreamChild
  • state is an identifier that identifies the name of the parameter. The name can be any one that satisfies the conditions of the name at least a at least E6 at least iamnotunder_stand - nick_n_a
  • @Atlantis thanks, it seems to be clear - Pavel Fedorov
  • @nick_n_a is understandable, but from where it takes it I do not understand, I did not find documentation on this. - Pavel Fedorov

1 answer 1

state is a variable with type bool which is a parameter of your function, it can accordingly be named arbitrarily.

And bool - only True / False values ​​are accepted.

The value of the parameter gets when calling this function. You can see where this function is used by right-clicking on it in the code and selecting the Find Usages

enter image description here

  • Yes, thanks for the hint, in general it is used only in two buttons, before the try block there is a ButtonState(false) and after the catch block there is a ButtonState(true) , I have more questions about how it works, as I understand it, until that What button is inactive in the try block? So? - Pavel Fedorov
  • @PavelFedorov when a function with the value true is called to the devotee in a parameter, the buttons become active. And when with false - the buttons are deactivated. - V. Dmitriy
  • so I thought correctly, @V. Dmitriy thanks for the clarification. - Pavel Fedorov