void Replace(ref string text, string toReplace, IGetName control) { //if contains && control != null -> replace string with object name if (text.Contains(toReplace) && control != null) { text = text.Replace(toReplace, control.GetObjectName()); } }