本文整理汇总了C#中NbtCompound.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# NbtCompound.ToList方法的具体用法?C# NbtCompound.ToList怎么用?C# NbtCompound.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NbtCompound
的用法示例。
在下文中一共展示了NbtCompound.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InterfaceImplementations
public void InterfaceImplementations()
{
NbtTag[] tagList = {
new NbtByte("First", 1), new NbtShort("Second", 2), new NbtInt("Third", 3),
new NbtLong("Fourth", 4L)
};
// test NbtCompound(IEnumerable<NbtTag>) constructor
var comp = new NbtCompound(tagList);
// test .Names and .Tags collections
CollectionAssert.AreEquivalent(new[] {
"First", "Second", "Third", "Fourth"
}, comp.Names);
CollectionAssert.AreEquivalent(tagList, comp.Tags);
// test ICollection and ICollection<NbtTag> boilerplate properties
ICollection<NbtTag> iGenCollection = comp;
Assert.IsFalse(iGenCollection.IsReadOnly);
ICollection iCollection = comp;
Assert.NotNull(iCollection.SyncRoot);
Assert.IsFalse(iCollection.IsSynchronized);
// test CopyTo()
var tags = new NbtTag[iCollection.Count];
iCollection.CopyTo(tags, 0);
CollectionAssert.AreEquivalent(comp, tags);
// test non-generic GetEnumerator()
var enumeratedTags = comp.ToList();
CollectionAssert.AreEquivalent(tagList, enumeratedTags);
// test generic GetEnumerator()
List<NbtTag> enumeratedTags2 = new List<NbtTag>();
var enumerator = comp.GetEnumerator();
while (enumerator.MoveNext()) {
enumeratedTags2.Add(enumerator.Current);
}
CollectionAssert.AreEquivalent(tagList, enumeratedTags2);
}