I have the following 2 overloaded staic methods defined in my static Class:
private static Dictionary<int, PartitionDefinition> GetNewPartitionDefinitions (string measureGroup, int rangeThreshold)
{
do something;
}
private static Dictionary<int, PartitionDefinition> GetNewPartitionDefinitions(DateRange startDateRange)
{
do something else;
}
The behavior I’m getting is which ever method is listed first in the code is the one that is recognized during design-time. The subsequent method name in the chain gets greyed out and I if I hover over it I receive the message ‘Method is never used’.
I have also noted that if I attempt to call the method, intellisense only detects the first one appearing in the code, like the other doesn’t exist.
Researching the problem I “believe” I can eliminate the condition of Type Erasure as being the issue but I’m not 100% absolutely certain of this.
I do know that the following code would constitute valid for Type Erasure using Generics:
public class A {
public static MethodOne (List<String> param) {}
public static MethodOne (Dictionary<String,String> param) {}
}
But in this case, the generics are being passed as parameters so I can see how this would cause a problem. In my instance, only the return types are identical Generic types but one would think that having the same method name and clearly having different non-generic parameter types and number should work.
Could someone please shed a bit of light on this? I have looked at similar article postings here, but none of them seem to describe the precise problem I am seeing.
I am not new to programming but I don’t claim to know everything and this one is a first for me.
The Message you receive might be because you are not using the methode in your code, the issue to overload static methods is actually allowed and shouldnt be a problem or cause any compiler error, you may want to check your configuration for the warnings and hints in VS.
I just tested it using this code: