.net - C# Cleanly assign every method parameter a single value -
i created function(shown below) assign text of 9 buttons " "(i try use " " instead of assigning variable null out of illogical assumption, appreciate pointed out if i'm incorrect), feel could've assigned every parameter blank string in cleaner way.
public void resettext(ref string buttontext1, ref string buttontext2, ref string buttontext3, ref string buttontext4, ref string buttontext5, ref string buttontext6, ref string buttontext7, ref string buttontext8, ref string buttontext9) { buttontext1 = ""; buttontext2 = ""; buttontext3 = ""; buttontext4 = ""; buttontext5 = ""; buttontext6 = ""; buttontext7 = ""; buttontext8 = ""; buttontext9 = ""; }
is there cleaner/shorter way reassign every parameter. pretty bad if have assign 50 variables new value in function(i used buttons example.)
this pretty best way this. simple , easy read.
you can buttontext1 = buttontext2 = buttontext3 = ... = "";
if want reduce character count.
another way of reducing code size reflection. not recommend going way since makes code overly complicated saving few characters.
Comments
Post a Comment