Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Hi, I was wondering if it was possible to compress this C# code into a function

I have six forms in my app and these lines of code are in every single one of them. I was wondering if it's possible to put it in a static method and use them throughout my code. I have no idea on how to pass stuff other than string, int, bool etc. into a function though, and even if i did. I don't think its possible to use labels in a class that isn't linked to a form. Any ideas?

lblScore.Text = "Score :" + frmLoginRegister.getPlayer().Score.ToString();     
lblLVL.Text = frmLoginRegister.getPlayer().Level.ToString();
pbLvlProgress.Value = frmLoginRegister.getPlayer().levelProgress;
pbChar.Image = Globals.AvatarPic;
lblUsername.Text = frmLoginRegister.getPlayer().Username;
lblTime.Text = "Time :";

Comments