Let's say I have the following code:
private void btnArr1(object sender, EventArgs e)
{
wr("test string1","st1");
}
private void btnArr2(object sender, EventArgs e)
{
wr("test string2","st2");
}
private void btnArr3(object sender, EventArgs e)
{
wr("test string3","st3");
}
private void wr(String str, String st){
switch(st){
case "st1":{
st1.Add(str);
break;
}
case "st2":{
st2.Add(str);
break;
}
case "st3":{
st3.Add(str);
break;
}
}
}
Is it somehow possible to minimize that code?
For example Change "st1.Add(str)" to something like "st".Add(str).
The only difference between those buttons is the list name where the information is stored. Everything else is equal.