Access form methods and variables from a class and vice versa in C#
问题 I am trying to finds a way to have access to methods and variables of a form and a class from each other using instance. Here is my code: My form code is: public partial class Form1 : Form { int var1 = 0; public Form1() { InitializeComponent(); Glob glob = new Glob(this); } private void button1_Click(object sender, EventArgs e) { } } and my class code is: public class Glob { private Form1 _form; public Glob(Form1 parent) { _form = parent; } public int Func1() { return 10; _form.var1 = 10; } }