小编Pra*_*rma的帖子

使用 ienumerable<T> 实现 ienumerable

在泛型集合类中使用 IEnumerable (Generic) 接口实现 IEnumerable (Non-generic) 需要什么?
msdn 上的代码示例说明(链接 - http://msdn.microsoft.com/en-us/library/9ekhta0(v=vs.110).aspx

public class App
{
// Excercise the Iterator and show that it's more 
// performant. 
public static void Main()
{
    TestStreamReaderEnumerable();
    TestReadingFile();
}

public static void TestStreamReaderEnumerable()
{
    // Check the memory before the iterator is used. 
    long memoryBefore = GC.GetTotalMemory(true);

    // Open a file with the StreamReaderEnumerable and check for a string. 
    var stringsFound =
        from line in new StreamReaderEnumerable(@"c:\\temp\\tempFile.txt")
        where line.Contains("string to search for")
        select line; …
Run Code Online (Sandbox Code Playgroud)

.net c# generics ienumerable interface

2
推荐指数
1
解决办法
1193
查看次数

标签 统计

.net ×1

c# ×1

generics ×1

ienumerable ×1

interface ×1