arraylist java c#_一个c#程序 急。如何用java中的arrayList方法来完成

这些是c#中的method的要求Set():ConstructsanemptysetEmpty:Returnstrueifthesetcontainsnoelement,elsefalse(read-only)Count:Returnsthenumberofelementsintheset(read-only)this...

这些是c#中的method的要求

Set() :Constructs an empty set

Empty :Returns true if the set contains no element, else false (read-only)

Count :Returns the number of elements in the set (read-only)

this[int index]:Returns the object at index (read-only), be sure and screen the index value that comes in to ensure it's within the range of your set

Contains(object o):Returns a bool, true if the Set contains the object, else false

Add(object o):Adds the object o to the Set if it is not contained already. Returns a bool, true if o was added, else false

Remove(object o):Removes the object o from the Set if it is present. Returns a bool, true if removed, else false

Equals(object o):Returns true if and only if two Set objects store the same values. (note: we are working with a set, therefore, order is unimportant).

GetHashCode():Returns an int value that is a representation of the Set. Two Set classes that are equal (method Equals() returns true) must also have equal GetHashCode() values.

ToString():Returns a string representation of the Set class. In the following format: [ value1, value2, value3, ] (a comma-separated list enclosed in square-brackets -- newlines between entries is ok).

以下是模板,需添加。在添加一个test, 使c#运行。

using System;

using System.Collections;

using System.Linq;

using System.Text;

/*

Name: Mengyi Gong

Class Description:

*/

namespace Assignment1

{

public class Set

{

ArrayList list = new ArrayList();

public Set()

{

// code... :)

}

public int Count

{

get

{

// ...

}

}

public bool Empty

{

get

{

// ...

}

}

public object this[int index]

{

get

{

// ...

}

}

public bool Contains(object o)

{

return list.Contains(o);

}

public bool Add(object o)

{

if (Contains(o) == true)

{

list.Add(o);

return true;

}

else

return false;

}

public bool Remove(object o)

{

list.Remove(o);

if (list.Count == 0)

return true;

else

return false;

}

public override bool Equals(object o)

{

// ...

}

public override int GetHashCode()

{

// ...

}

public override string ToString()

{

string temp = null;

return temp;

}

}

}

额。。那就是用c#的arraylist,对c#不熟悉 才学一周 这个实在是不会了 还请各位高手帮帮我吧

展开

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值