I have two items in my class: One is a public property, and the other is a static method that takes a parameter.
I really do not understand why Visual Studio 2010 is unable to see the difference between these two items.
Could someone explain this one to me?
Here is the code:
public bool IsShipped {
get {
#region ' Test Code '
if (!String.IsNullOrEmpty(TrailerNo) || (TruckDate != Global.NODATE)) {
return true;
}
#endregion
return false;
}
}
public static bool IsShipped(string boxNumber) {
var array = GetCrate(boxNumber);
if (array != null) {
foreach (var item in array) {
if (item.IsShipped) {
return true;
}
}
}
return false;
}
Here is the error:
Error 1 Ambiguity between ‘AcpClasses.AcpPackNShip.IsShipped’ and ‘AcpClasses.AcpPackNShip.IsShipped(string)’ C:\Users\cp-jpool\My Projects\VS\Live\Common\Classes\AcpPackShip.cs 242 20 CoilPC

It’s possible to refer to a method as a delegate, not just by calling it. For example, the following could would be valid use of the method:
Given that the method doesn’t need to be actually called with parenthesis, there is no way of determining if
item.IsShippedis supposed to refer to the method group forIsShippedor to be the propertyIsShipped.Even if it were allowed, it would be a point likely to result in confusion. It would be preferable from a code maintenance perspective to have different names for the property/method, even if the compiler were somehow smart enough to know which one to use when (or worse, if it just picked one arbitrarily).