В данном примере, цикл будет обходить все элементы управления. Если элемент управления имеет тип текстового поля, то оно будет очищено от значения. Кто еще не догадался, это было описание работы кнопки Очистить.
   
 
     Counter.cs  
     
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;classCounter {-  
ushortshowStart; -  
ushortshowEnd; -  
decimalprice; -  
publicCounter(stringarg0,stringarg1,stringarg2) { -   
ushort.TryParse(arg0,outshowStart); -   
ushort.TryParse(arg1,outshowEnd); -   
decimal.TryParse(arg2,outprice); -  
} -  
publicushortResultShow() { -   
return(ushort)(showEnd - showStart); -  
} -  
publicdecimalSum() { -   
returnMath.Round((decimal)(ResultShow() * price) , 2); -  
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;classCounter {-  
ushortshowStart; -  
ushortshowEnd; -  
decimalprice; -  
publicCounter(stringarg0,stringarg1,stringarg2) { -   
ushort.TryParse(arg0,outshowStart); -   
ushort.TryParse(arg1,outshowEnd); -   
decimal.TryParse(arg2,outprice); -  
} -  
publicushortResultShow() { -   
return(ushort)(showEnd - showStart); -  
} -  
publicdecimalSum() { -   
returnMath.Round((decimal)(ResultShow() * price) , 2); -  
} }
  Form1.cs  
     
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0025 {-  
publicpartialclassForm1 : Form { -   
publicForm1() { -    
InitializeComponent(); -   
} -   
privatevoidbutton1_Click(objectsender, EventArgs e) { -    
Counter C =newCounter(textBox1.Text, textBox2.Text, textBox3.Text); -    
textBox4.Text = C.Sum().ToString(); -   
} -   
privatevoidbutton2_Click(objectsender, EventArgs e) { -    
//кнопка очищает все текстовые поля -    
foreach(Control iinControls) { -     
if(i.GetType() ==typeof(TextBox)) { -      
i.Text =string.Empty; -     
} -    
} -   
} -  
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0025 {-  
publicpartialclassForm1 : Form { -   
publicForm1() { -    
InitializeComponent(); -   
} -   
privatevoidbutton1_Click(objectsender, EventArgs e) { -    
Counter C =newCounter(textBox1.Text, textBox2.Text, textBox3.Text); -    
textBox4.Text = C.Sum().ToString(); -   
} -   
privatevoidbutton2_Click(objectsender, EventArgs e) { -    
//кнопка очищает все текстовые поля -    
foreach(Control iinControls) { -     
if(i.GetType() ==typeof(TextBox)) { -      
i.Text =string.Empty; -     
} -    
} -   
} -  
} }