how to return a value from main form to a differnt form or class(C#)

前端 未结 3 1043
慢半拍i
慢半拍i 2021-01-22 02:38

For some unknown reasons this silly thing cant be implemented.

I have an int count in the main form which I want to return to another class or form.

<
3条回答
  •  日久生厌
    2021-01-22 03:00

    Where do you show the form? What you're doing is code is simply creating a new instance of the login form, and reading the nameCount value, which is still at its initialized value: 0.

    I think you should use ShowDialog and return the result in a DialogResult. If that's OK, then read the count value.

提交回复
热议问题