我怎样才能重构它,这样我就不会在每种方法中重复相同的代码?
private void setupTooltip(Grid obj)
{
var controls = obj.Children.OfType<System.Windows.Controls.TextBox>();
foreach (var control in controls)
{
control.ToolTip = "Code is <" + control.Name + ">";
}
}
private void setupTooltip(StackPanel obj)
{
var controls = obj.Children.OfType<System.Windows.Controls.TextBox>();
foreach (var control in controls)
{
control.ToolTip = "Code is <" + control.Name + ">";
}
}