本文整理汇总了C#中Microsoft.VisualBasic.Collection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Collection.Add方法的具体用法?C# Collection.Add怎么用?C# Collection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.VisualBasic.Collection
的用法示例。
在下文中一共展示了Collection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAfterNoKey
public void AddAfterNoKey()
{
Collection c;
c = new Collection ();
c.Add (typeof (int), null, null, 0);
c.Add (typeof (double), null, null, 1);
c.Add (typeof (string), null, null, 1);
c.Add (typeof (object), null, null, 3);
Assert.AreEqual (4, c.Count, "#AANK01");
Assert.AreEqual (typeof (object), c[4], "#AANK02");
Assert.AreEqual (typeof (int), c[1], "#AANK03");
Assert.AreEqual (typeof (string), c[2], "#AANK04");
}
示例2: Start
public override void Start()
{
try
{
if (base.m_ItemsSelecteds.Count > 0)
{
using (ISession Sesion = m_SessionFactory.OpenSession())
{
Collection ObjectsFlow = new Collection();
foreach (String ID in base.m_ItemsSelecteds)
{
Parent Entity = (Parent)Sesion.Get(base.m_EntidadSF.NombreClase, ID);
Entity.NewInstance = false;
ObjectsFlow.Add(Entity);
}
base.m_ObjectFlow = ObjectsFlow;
base.m_ResultProcess = EnumResult.SUCESS;
}
}
}
catch (Exception ex)
{
base.m_ResultProcess = EnumResult.ERROR;
SoftException.Control(ex);
}
base.Start();
}
示例3: AddAfterKey
public void AddAfterKey()
{
Collection c;
c = new Collection ();
c.Add ("Baseball", "Base", null, 0);
c.Add ("Football", "Foot", null, 1);
c.Add ("Basketball", "Basket", null, 1);
c.Add ("Volleyball", "Volley", null, 2);
Assert.AreEqual (4, c.Count, "#AAK01");
Assert.AreEqual ("Baseball", c[1], "#AAK02");
Assert.AreEqual ("Football", c[4], "#AAK03");
Assert.AreEqual ("Basketball", c["Basket"], "#AAK04");
Assert.AreEqual ("Volleyball", c["Volley"], "#AAK05");
}
示例4: Add_Key_1
public void Add_Key_1()
{
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
string s3 = "c";
col.Add(s2,"key2",null,null);
col.Add(s1,"key3",null,null);
col.Add(s3,"key1",null,null);
Assert.AreEqual(3,col.Count);
Assert.AreEqual(s2,col[1]);
Assert.AreEqual(s1,col[2]);
Assert.AreEqual(s3,col[3]);
Assert.AreEqual(s1,col["key3"]);
Assert.AreEqual(s2,col["key2"]);
Assert.AreEqual(s3,col["key1"]);
}
示例5: Add_Key_2
public void Add_Key_2()
{
// Add failed. Duplicate key value supplied.
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
col.Add(s2,"key",null,null);
col.Add(s1,"key",null,null);
}
示例6: AddBeforeKey
public void AddBeforeKey()
{
Collection c;
c = new Collection ();
c.Add ("Baseball", "Base", null, null);
c.Add ("Football", "Foot", 1, null);
c.Add ("Basketball", "Basket", 1, null);
c.Add ("Volleyball", "Volley", 3, null);
Assert.AreEqual (4, c.Count, "#ABK01");
Assert.AreEqual ("Basketball", c[1], "#ABK02");
Assert.AreEqual ("Baseball", c[4], "#ABK03");
Assert.AreEqual ("Volleyball", c["Volley"], "#ABK04");
Assert.AreEqual ("Football", c["Foot"], "#ABK05");
}
示例7: Index_9
public void Index_9()
{
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
col.Add(s1,"key1",null,null);
col.Add(s2,"key2",null,null);
System.Collections.IList il = (System.Collections.IList)col;
il[0] = "q";
il[1] = "r";
object o = il[1];
}
示例8: GetEnumerator
public void GetEnumerator()
{
Collection c;
IEnumerator e;
object[] o = new object[4] {typeof(int),
typeof(double), typeof(string), typeof(object)};
int i = 0;
c = new Collection ();
c.Add (typeof (int), null, null, null);
c.Add (typeof (double), null, null, null);
c.Add (typeof (string), null, null, null);
c.Add (typeof (object), null, null, null);
e = c.GetEnumerator ();
Assert.IsNotNull (e, "#GE01");
while (e.MoveNext ())
{
Assert.AreEqual (o[i], e.Current, "#GE02." + i.ToString ());
i++;
}
e.Reset ();
e.MoveNext ();
Assert.AreEqual (o[0], e.Current, "#GE03");
}
示例9: GetEnumerator_10
public void GetEnumerator_10()
{
Collection col = new Collection();
Byte o1 = 1;
short o2 = 1;
int o3 = 1;
long o4 = 1000;
col.Add(o1,null,null,null);
col.Add(o2,null,null,null);
col.Add(o3,null,null,null);
IEnumerator en = col.GetEnumerator();
col.Add(o4,null,1,null);
en.MoveNext();
Assert.AreEqual(o4,en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual(o1,en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual(o2,en.Current);
Assert.IsTrue(en.MoveNext());
Assert.AreEqual(o3,en.Current);
Assert.IsFalse(en.MoveNext());
Assert.AreEqual(null,en.Current);
col.Add(o4,null,null,null);
Assert.AreEqual(null,en.Current);
Assert.IsFalse(en.MoveNext());
}
示例10: Dirty_Read
public void Dirty_Read()
{
Collection col = new Collection();
string s = "abc";
col.Add(s,null,null,null);
col.Add(s,null,null,null);
col.Add(s,null,null,null);
col.Add(s,null,null,null);
object o = col["abc"];
}
示例11: RemoveNoKey
public void RemoveNoKey()
{
Collection c;
c = new Collection ();
c.Add (typeof (int), null, null, null);
c.Add (typeof (double), null, null, null);
c.Add (typeof (string), null, null, null);
c.Add (typeof (object), null, null, null);
Assert.AreEqual (4, c.Count, "#RNK01");
c.Remove (3);
Assert.AreEqual (3, c.Count, "#RNK02");
// Collection class is 1-based
Assert.AreEqual (typeof (object), c[3], "#RNK03");
c.Remove (1);
Assert.AreEqual (2, c.Count, "#RNK04");
Assert.AreEqual (typeof (double), c[1], "#RNK05");
Assert.AreEqual (typeof (object), c[2], "#RNK06");
c.Remove (2);
Assert.AreEqual (1, c.Count, "#RNK07");
Assert.AreEqual (typeof (double), c[1], "#RNK08");
c.Remove (1);
Assert.AreEqual (0, c.Count, "#RNK09");
}
示例12: Remove_6
public void Remove_6()
{
// Argument 'Key' is not a valid value.
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
string s3 = "c";
col.Add(s2,"keya",null,null);
col.Add(s1,"keyb",null,null);
col.Add(s3,"keyc",null,null);
col.Remove("keyd");
}
示例13: Remove_7
public void Remove_7()
{
// Key cannot be null
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
string s3 = "c";
col.Add(s2,"keya",null,null);
col.Add(s1,"keyb",null,null);
col.Add(s3,"keyc",null,null);
col.Remove(null);
}
示例14: Remove_5
public void Remove_5()
{
// Collection index must be in the range 1 to the size of the collection.
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
string s3 = "c";
col.Add(s2,"keya",null,null);
col.Add(s1,"keyb",null,null);
col.Add(s3,"keyc",null,null);
col.Remove(4);
}
示例15: Remove_2
public void Remove_2()
{
Collection col = new Collection();
string s1 = "a";
string s2 = "b";
string s3 = "c";
col.Add(s2,"keya",null,null);
col.Add(s1,"keyb",null,null);
col.Add(s3,"keyc",null,null);
col.Add(s2 + s1,"keyd",null,null);
col.Add(s1 + s1,"keye",null,null);
col.Add(s3 + s1,"keyf",null,null);
col.Remove("keya");
Assert.AreEqual(5,col.Count);
Assert.AreEqual("a",col[1]);
Assert.AreEqual("c",col[2]);
Assert.AreEqual("ba",col[3]);
Assert.AreEqual("aa",col[4]);
Assert.AreEqual("ca",col[5]);
col.Remove("keyd");
Assert.AreEqual(4,col.Count);
Assert.AreEqual("a",col[1]);
Assert.AreEqual("c",col[2]);
Assert.AreEqual("aa",col[3]);
Assert.AreEqual("ca",col[4]);
col.Remove("keyf");
Assert.AreEqual(3,col.Count);
Assert.AreEqual("a",col[1]);
Assert.AreEqual("c",col[2]);
Assert.AreEqual("aa",col[3]);
col.Remove("keyc");
Assert.AreEqual(2,col.Count);
Assert.AreEqual("a",col[1]);
Assert.AreEqual("aa",col[2]);
col.Remove("keyb");
Assert.AreEqual(1,col.Count);
Assert.AreEqual("aa",col[1]);
col.Remove("keye");
Assert.AreEqual(0,col.Count);
}