Requires two classes
1. TypeFiles.cs
Copy Code code as follows:
Using System;
Namespace Model
{
<summary>
Summary description of the 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 code as follows:
Using System;
Using System.Collections;
Namespace Command
{
<summary>
Summary description of the Wehash.
</summary>
public class Wehash
{
Private ArrayList alist = new ArrayList ();
Public Wehash ()
{
//
TODO: Add constructor logic here
//
}
public void Add (object key,object value,object valtype)
{
Model.typefiles cmt=new model.typefiles ();
Cmt. Fkey = key;
Cmt. Fvalue1 = value;
Cmt. Fvalue2 = Valtype;
Alist. ADD (CMT);
}
Public ArrayList Hashitems
{
Get
{
return alist;
}
Set
{
Alist = value;
}
}
public bool Hascontaint (object key)
{
foreach (Object itm in Alist)
{
Model.typefiles CMT = (model.typefiles) itm;
if (CMT). Fkey.tostring () = key. ToString ())
return true;
}
return false;
}
}
}
Several constructors can be defined in the TypeFiles.cs (so that hash.add can be more)
How to use:
Command.wehash cw=new Wehash ();
cw. ADD ("KeyName1", "value1", "value2");
cw. ADD ("KeyName2", "value1", "value2");
cw. ADD ("KeyName3", "value1", "value2");
And then the CW. Hashitems is passed to the party to be manipulated.
To make. Add more items, you need to make TypeFiles.cs constructs a few more, and then modify
public void Add (object key,object value,object valtype)
{
Model.typefiles cmt=new model.typefiles ();
Cmt. Fkey = key;
Cmt. Fvalue1 = value;
Cmt. Fvalue2 = Valtype;
.... The remaining CMT items.
Alist. ADD (CMT);
}