本文整理汇总了C#中System.CodeDom.CodeExpressionCollection.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# CodeExpressionCollection.IndexOf方法的具体用法?C# CodeExpressionCollection.IndexOf怎么用?C# CodeExpressionCollection.IndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.CodeDom.CodeExpressionCollection
的用法示例。
在下文中一共展示了CodeExpressionCollection.IndexOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor1
public void Constructor1 ()
{
CodeExpression exp1 = new CodeExpression ();
CodeExpression exp2 = new CodeExpression ();
CodeExpression[] expressions = new CodeExpression[] { exp1, exp2 };
CodeExpressionCollection coll = new CodeExpressionCollection (
expressions);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (exp1), "#2");
Assert.AreEqual (1, coll.IndexOf (exp2), "#3");
}
示例2: Constructor0_Deny_Unrestricted
public void Constructor0_Deny_Unrestricted ()
{
CodeExpressionCollection coll = new CodeExpressionCollection ();
Assert.AreEqual (0, coll.Add (ce), "Add");
Assert.AreSame (ce, coll[0], "this[int]");
coll.CopyTo (array, 0);
coll.AddRange (array);
coll.AddRange (coll);
Assert.IsTrue (coll.Contains (ce), "Contains");
Assert.AreEqual (0, coll.IndexOf (ce), "IndexOf");
coll.Insert (0, ce);
coll.Remove (ce);
}
示例3: Constructor2
public void Constructor2 ()
{
CodeExpression exp1 = new CodeExpression ();
CodeExpression exp2 = new CodeExpression ();
CodeExpressionCollection c = new CodeExpressionCollection ();
c.Add (exp1);
c.Add (exp2);
CodeExpressionCollection coll = new CodeExpressionCollection (c);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (exp1), "#2");
Assert.AreEqual (1, coll.IndexOf (exp2), "#3");
}
示例4: Remove
public void Remove ()
{
CodeExpression ce1 = new CodeExpression ();
CodeExpression ce2 = new CodeExpression ();
CodeExpressionCollection coll = new CodeExpressionCollection ();
coll.Add (ce1);
coll.Add (ce2);
Assert.AreEqual (2, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (ce1), "#2");
Assert.AreEqual (1, coll.IndexOf (ce2), "#3");
coll.Remove (ce1);
Assert.AreEqual (1, coll.Count, "#4");
Assert.AreEqual (-1, coll.IndexOf (ce1), "#5");
Assert.AreEqual (0, coll.IndexOf (ce2), "#6");
}
示例5: AddRange
public void AddRange ()
{
CodeExpression exp1 = new CodeExpression ();
CodeExpression exp2 = new CodeExpression ();
CodeExpression exp3 = new CodeExpression ();
CodeExpressionCollection coll1 = new CodeExpressionCollection ();
coll1.Add (exp1);
coll1.Add (exp2);
CodeExpressionCollection coll2 = new CodeExpressionCollection ();
coll2.Add (exp3);
coll2.AddRange (coll1);
Assert.AreEqual (3, coll2.Count, "#1");
Assert.AreEqual (1, coll2.IndexOf (exp1), "#2");
Assert.AreEqual (2, coll2.IndexOf (exp2), "#3");
Assert.AreEqual (0, coll2.IndexOf (exp3), "#4");
CodeExpressionCollection coll3 = new CodeExpressionCollection ();
coll3.Add (exp3);
coll3.AddRange (new CodeExpression[] { exp1, exp2 });
Assert.AreEqual (3, coll2.Count, "#5");
Assert.AreEqual (1, coll2.IndexOf (exp1), "#6");
Assert.AreEqual (2, coll2.IndexOf (exp2), "#7");
Assert.AreEqual (0, coll2.IndexOf (exp3), "#8");
}
示例6: Insert
public void Insert ()
{
CodeExpression exp1 = new CodeExpression ();
CodeExpression exp2 = new CodeExpression ();
CodeExpressionCollection coll = new CodeExpressionCollection ();
coll.Add (exp1);
Assert.AreEqual (1, coll.Count, "#1");
Assert.AreEqual (0, coll.IndexOf (exp1), "#2");
coll.Insert (0, exp2);
Assert.AreEqual (2, coll.Count, "#3");
Assert.AreEqual (1, coll.IndexOf (exp1), "#4");
Assert.AreEqual (0, coll.IndexOf (exp2), "#5");
}