Dhairya Bhardwaj Dhairya Bhardwaj - 1 year ago 58
C# Question

How to use Array.Sort method in a Programmer defined partial Array class in c#?

Hey everyone I was trying to extended an

with a user defined method (
) in context of my Program. so I use the following code :

partial class Array{
public static object MajorityElementOf(int[] arr)
//rest of the code

Compiling this is giving an error:

'Array' does not contain a definition for 'Sort';

It may be due to the
method is not defined in this part of
. Can anyone tell me how to use
method in this code ?

Answer Source

Your problem is your Array class takes precedence in effect hiding the other class. You can use the full namespace to get around this, for example:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download