Two classes are required.
1. typefiles. CS
CopyCode The Code is as follows: using system;
Namespace Model
{
/// <Summary>
/// Summary of typefiles.
/// </Summary>
Public class typefiles
{
Private object _ fkey;
Private object _ fvalue1;
Private object _ fvalue2;
Public object fkey
{
Get
{
Return _ fkey;
}
Set
{
_ Fkey = value;
}
}
Public object fvalue1
{
Get
{
Return _ fvalue1;
}
Set
{
_ Fvalue1 = value;
}
}
Public object fvalue2
{
Get
{
Return _ fvalue2;
}
Set
{
_ Fvalue2 = value;
}
}
}
}
2. wehash. CS (hashtable class, combined with arraylist) copy Code the code is as follows: using system;
using system. collections;
namespace command
{< br> ///
// wehash summary.
//
public class wehash
{< br> private arraylist alist = new arraylist ();
Public wehash ()
{< br> //
// todo: add the constructor logic
//
}< br> Public void add (Object key, object value, object valtype)
{< br> model. typefiles CMT = new model. typefiles ();
cmt. fkey = key;
cmt. fvalue1 = value;
cmt. fvalue2 = valtype;
alist. add (CMT);
}< br> Public arraylist hashitems
{< br> Get
{< br> return alist;
}< br> set
{< br> alist = value;
}< BR >}< br> Public bool hascontaint (Object key)
{< br> foreach (Object ITM in alist)
{< br> model. typefiles CMT = (model. typefiles) ITM;
If (CMT. fkey. tostring () = key. tostring ()
return true;
}< br> return false;
}< BR >}
typefiles. several constructors can be defined in CS (such as hash. add (multiple items)
usage:
command. wehash CW = new wehash ();
CW. add ("keyname1", "value1", "value2");
CW. add ("keyname2", "value1", "value2");
CW. add ("keyname3", "value1", "value2");
. send hashitems to the operator.
to enable. add to add more items, you need to make typefiles. CS constructs several more parts, and then modifies
Public void add (Object key, object value, object valtype)
{< br> model. typefiles CMT = new model. typefiles ();
cmt. fkey = key;
cmt. fvalue1 = value;
cmt. fvalue2 = valtype;
.... other CMT items.
alist. add (CMT);
}