I'm sure everyone's encountered their share of developers who love the ToString() method. We've all likely seen code similar to the following:
public static bool CompareIfAnyMatchesOrHasEmpty(List<string> list1, List<string> list2) { bool result = false; foreach (string item1 in list1) { foreach (string item2 in list2) { if (item1.ToString() == item2.ToString()) { result = true; } if (item1.ToString() == "") { result = true; } } } return result; } What I'm wondering is if the ToString() method (the empty, no formatting one) can be optimized away by the compiler? My assumption is that it does not, since it's originally defined on object. Thus I provide this second question, on if any effort to cleanup such instances would be worthwhile?