class ArrayTest
{
public string[] RemoveDups(string[] s)
{
var count = s.Count();
string[] arr = new String[count];
for (int i = 0; i < count; i++)
{
if (!arr.Contains(s[i]))
{
arr[i] = s[i];
}
}
return arr;
}
public int[] RemoveDuplicationValues(int[] values)
{
var result = new ArrayList();
foreach (int s in values)
{
if (!result.Contains(s))
{
result.Add(s);
}
}
return (int[])result.ToArray(typeof(int));
}
}
{
public string[] RemoveDups(string[] s)
{
var count = s.Count();
string[] arr = new String[count];
for (int i = 0; i < count; i++)
{
if (!arr.Contains(s[i]))
{
arr[i] = s[i];
}
}
return arr;
}
public int[] RemoveDuplicationValues(int[] values)
{
var result = new ArrayList();
foreach (int s in values)
{
if (!result.Contains(s))
{
result.Add(s);
}
}
return (int[])result.ToArray(typeof(int));
}
}
No comments:
Post a Comment