here it is:
Code:
using System;
using System.Collections;
public class Test
{
public static SortedList s1 = new SortedList();
public static SortedList s2 = new SortedList();
static void Maker()
{
s1.Add(1, "daniel");
s1.Add(2, "aceman");
s2.Add(1, "daniel");
s2.Add(2, "aceman");
}
static void Main()
{
Maker();
bool result = Testi(s1, s2);
bool result1 = Equals(s1, s2);
Console.WriteLine(result);
Console.WriteLine(result1);
}
public static override bool Equals(object obj1, object obj2) {
SortedList s1 = obj1 as SortedList;
SortedList s2 = obj2 as SortedList;
int j = 0;
bool a = false;
if(s1.Count == s2.Count)
{
a = true;
for(int i = 0; i < s1.Count; i++)
{
if(s1.GetKey(i).Equals(s2.GetKey(i))) j++;
}
for(int i = 0; i < s1.Count; i++)
{
if(s1.GetByIndex(i).Equals(s2.GetByIndex(i))) j++;
}
}
if((a == true) && (j == (s1.Count)*2)) return true;
else return true;
}
static bool Testi(SortedList s1, SortedList s2)
{
int j = 0;
bool a = false;
if(s1.Count == s2.Count)
{
a = true;
for(int i = 0; i < s1.Count; i++)
{
if(s1.GetKey(i).Equals(s2.GetKey(i))) j++;
}
for(int i = 0; i < s1.Count; i++)
{
if(s1.GetByIndex(i).Equals(s2.GetByIndex(i))) j++;
}
}
if((a == true) && (j == (s1.Count)*2)) return true;
else return true;
}
}
overriding Equals(object obj) and appropriate code also return false, even if i only put into it onlt {return true;}
:?