Created
January 16, 2020 01:35
-
-
Save ABaker86/090a20f0e40fa4de8b2eea76149cf018 to your computer and use it in GitHub Desktop.
Update control using Action to keep code DRY
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Action<Label, string, Point, Font> Up => (l, s, p, f) => | |
{ | |
l.Text = s; | |
l.Size = new Size(p); | |
l.Font = f; | |
}; | |
void UpdateLblOne() => Up(lblOne, TEXT, SIZE, FONT); | |
void UpdateLblTwo() => Up(label2, TEXT, SIZE, FONT); | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
UpdateLblOne(); | |
UpdateLblTwo(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment