>The type in your List must implement the IComparable interface in order for the Sort to be able to work. I just checked and ServiceController does not seem to implement that interface ... so I don't think that's going to work for you at all.
Just write your own (see my reply to Kevin) :-}
>
>I can think of three workarounds off the top of my head (haven't tried either one):
>
>1) Have two Lists, one that is simply a list of names of the services that you can sort, then of course you'd have to find the corresponding service in your Services list.
>
>2) Use a Dictionary or a SortedDictionary, where the Key is the ServiceName and the Value is the actual Service class.
>
>3) Use a SortedList.
>
>
>~~Bonnie
>
>
>
>>I have loaded a list with Windows Services:
>>
>>
>>public static List<ServiceController> GetAllServices()
>>{
>> ServiceController[] Temp = ServiceController.GetServices();
>> List<ServiceController> Services = new List<ServiceController>(Temp);
>> Services.Sort();
>>
>> return Services;
>>}
>>
>>
>>The Sort line throws the error "Failed to compare two elements in the array." Google hits are obscure on this. Anyone know what this is about?