Заданы интерфейс и класс.
interface IList
{
int CompareTo(object obj);
int Contains(string type);
}
class ListObj:IList
{
public Type TypL { get { return obj.GetType(); } }
ListObj Next,last;
int count=0;
public int Count { get{
return count; } }
object obj;
public ListObj() { last= null; count = 0; }
public ListObj(object objP) {
obj = objP; count = 1;Next = null;last= this;
}
public ListObj(object[] Aobj)
{
foreach (object t in Aobj) Add(t);
}
public void Add(Object objP)
{
if (last == null)
{ obj = objP;count = 1;last = this; return; }
last.Next = new ListObj();
last.Next.obj = objP;
count++;
last = last.Next;
}
public int CompareTo(object L)
{ return Count - ((ListObj)L).Count; }
public int Contains(string type)
{
int cnt=0;
string tt;
ListObj t;
for ( t = this; t != this.last; t = t.Next)
{ if ((tt=t.obj.GetType().Name) == type) cnt++; }
if ((t.obj.GetType().Name) == type) cnt++;
return cnt;
}
public override string ToString()
{
string s = "";
ListObj t;
if (last == null) return "";
for (t = this; t != last; t = t.Next)
s += t.obj+" ";
s += t.obj;
return s;
}
}
Требуется записать что выведет программа
Console.Write(L.Contains("String"));
Console.Write(L.Contains(L.GetType().Name));
Console.WriteLine(L.Contains("Int32"));
Если L=(1, 2)
Приведите обоснование ответа.
| Гарантия на работу | 1 год |
| Средний балл | 4.53 |
| Стоимость | Назначаете сами |
| Эксперт | Выбираете сами |
| Уникальность работы | от 70% |