本文整理汇总了C#中JsonValue.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# JsonValue.Contains方法的具体用法?C# JsonValue.Contains怎么用?C# JsonValue.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonValue
的用法示例。
在下文中一共展示了JsonValue.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArrayOperations
public void ArrayOperations()
{
JsonValue test = new JsonValue() { 1, 2, 3 };
Assert.That(test.Count, Is.EqualTo(3));
Assert.That(test.Contains(1), Is.True);
Assert.That(test.Contains(4), Is.False);
JsonValue[] values = new JsonValue[3];
test.CopyTo(values, 0);
for (int i = 0; i < 3; i++) {
Assert.That((int)values[i], Is.EqualTo((int)test[i]));
}
test.Remove(2);
Assert.That(test.Contains(1), Is.True);
Assert.That(test.Contains(2), Is.False);
Assert.That(test.Contains(3), Is.True);
Assert.That(test.IsReadOnly, Is.False);
Assert.That(test.IndexOf(1), Is.EqualTo(0));
test.Insert(1, 2);
Assert.That((int)test[1], Is.EqualTo(2));
Assert.That(test.Count, Is.EqualTo(3));
test.RemoveAt(1);
Assert.That((int)test[1], Is.EqualTo(3));
Assert.That(test.Count, Is.EqualTo(2));
test.Clear();
Assert.That(test.Count, Is.EqualTo(0));
test.Add(5);
Assert.That(test.Count, Is.EqualTo(1));
Assert.That((int)test[0], Is.EqualTo(5));
}
示例2: KVPCollection
public void KVPCollection()
{
JsonValue test = new JsonValue() {
{"one", 1},
{"two", 2},
{"three", 3},
};
test.Remove(new KeyValuePair<string, JsonValue>("one", 1));
Assert.That(test.Count, Is.EqualTo(2));
Assert.Throws<KeyNotFoundException>(() => test["one"].ToString());
KeyValuePair<string, JsonValue>[] dest = new KeyValuePair<string, JsonValue>[2];
test.CopyTo(dest, 0);
for (int i = 0; i < 2; ++i) {
Assert.That(test[dest[i].Key].Equals(dest[i].Value));
}
Assert.That(test.Contains(new KeyValuePair<string, JsonValue>("two", 2)));
test.Add(new KeyValuePair<string, JsonValue>("four", 4));
Assert.That(test.ContainsKey("four"), Is.True);
Assert.That((int)test["four"], Is.EqualTo(4));
}