本文整理汇总了C#中System.Collections.ArrayList.OfType方法的典型用法代码示例。如果您正苦于以下问题:C# System.Collections.ArrayList.OfType方法的具体用法?C# System.Collections.ArrayList.OfType怎么用?C# System.Collections.ArrayList.OfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ArrayList
的用法示例。
在下文中一共展示了System.Collections.ArrayList.OfType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestLinqOfType
public void TestLinqOfType()
{
var connectionString = _connectionString + "StoreName=" + Guid.NewGuid();
var context = new MyEntityContext(connectionString);
var entity1 = context.Entities.Create();
entity1.SomeString = "An entity";
var animal1 = context.Animals.Create();
animal1.Name = "Mutley";
var person1 = context.Persons.Create();
person1.Name = "Jen Williams";
var company1 = context.Companies.Create();
company1.Name = "Networked Planet";
var person2 = context.Persons.Create();
person2.Name = "Kal Ahmed";
var entity2 = context.Entities.Create();
entity2.SomeString = "Another entity";
context.SaveChanges();
Assert.AreEqual(2, context.Persons.Count());
Assert.AreEqual(2, context.Entities.Count());
Assert.AreEqual(1, context.Companies.Count());
Assert.AreEqual(1, context.Animals.Count());
var arrayList = new System.Collections.ArrayList(5) {entity1, animal1, person1, company1, person2, entity2};
var entities = arrayList.OfType<Entity>();
Assert.AreEqual(2, entities.Count());
}