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