本文整理汇总了C#中OrderedDictionary.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# OrderedDictionary.IndexOf方法的具体用法?C# OrderedDictionary.IndexOf怎么用?C# OrderedDictionary.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OrderedDictionary
的用法示例。
在下文中一共展示了OrderedDictionary.IndexOf方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OrderedDictionary
public void OrderedDictionary()
{
OrderedDictionary<string, int> dict = new OrderedDictionary<string, int>();
DoTests(dict);
Assert.AreEqual(3, dict. Count, "Has 3 records left");
Assert.AreEqual(2, dict.IndexOf("test4"), "IndexOf works");
Assert.AreEqual(dict[1], 30, "Access by numeric index appears to work");
Assert.AreEqual(dict.Values[1], 30, "Access to values by index is good");
Assert.AreEqual(dict.Keys[1], "test3", "Access to values by index is good");
Assert.Throws<NotSupportedException>(Del(()=>{dict.Values[1]=333;}),"Can't set value when accessing it from the Values list");
dict.Insert(0, 100);
// indicies should have moved
Assert.AreEqual(4, dict.Count, "Has 3 records left");
Assert.AreEqual(3, dict.IndexOf("test4"), "IndexOf works");
Assert.AreEqual(dict[2], 30, "Access by numeric index appears to work");
Assert.AreEqual(dict[0], 100);
// check for autocreated key
Assert.AreEqual(dict.Keys[0],"0", "Autogenerated a key.");
dict.Insert(0, 100);
Assert.AreEqual(dict.Keys[0], "1", "Autogenerated another key.");
}
示例2: IndexOf_StartIndex_KeyNull
public void IndexOf_StartIndex_KeyNull()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.Add("baz", 2);
dict.Add("monkeys", 3);
dict.IndexOf (null, 1);
}
示例3: IndexOf_StartIndex_NotFound
public void IndexOf_StartIndex_NotFound()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.Add("baz", 2);
dict.Add("monkeys", 3);
Assert.AreEqual (-1, dict.IndexOf ("asdf", 2));
Assert.AreEqual (-1, dict.IndexOf ("bar", 2));
}
示例4: IndexOf_StartIndex_IndexOutOfRangeUpper
public void IndexOf_StartIndex_IndexOutOfRangeUpper()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.Add("baz", 2);
dict.Add("monkeys", 3);
dict.IndexOf("monkeys", 5);
}
示例5: IndexOf_StartIndexAndCount_CountOutOfRange
public void IndexOf_StartIndexAndCount_CountOutOfRange()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.Add("baz", 2);
dict.Add("monkeys", 3);
dict.IndexOf("monkeys", 2, 3);
}
示例6: IndexOf_StartIndexAndCount
public void IndexOf_StartIndexAndCount()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.Add("baz", 2);
dict.Add("monkeys", 3);
Assert.AreEqual(1, dict.IndexOf("bar", 1, 1));
Assert.AreEqual(2, dict.IndexOf("baz", 0, 3));
}
示例7: IndexOf_NotFound
public void IndexOf_NotFound()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
Assert.AreEqual(-1, dict.IndexOf("baz"));
}
示例8: IndexOf_KeyNull
public void IndexOf_KeyNull()
{
var dict = new OrderedDictionary<string, int>();
dict.Add("foo", 0);
dict.Add("bar", 1);
dict.IndexOf (null);
}