.NET Framework 4 中的新增功能

参考: http://msdn.microsoft.com/zh-cn/library/w0x726c2.aspx

增强功能

1. 如何:枚举目录和文件

返回可枚举集合的方法的指南

要枚举的项

要返回的可枚举集合

要使用的方法

目录

枚举目录名称。

Directory.EnumerateDirectories

 

目录信息 (DirectoryInfo)。

DirectoryInfo.EnumerateDirectories

文件

枚举所有目录中的文件名称。

Directory.EnumerateFiles

 

文件信息 (FileInfo)。

DirectoryInfo.EnumerateFiles

文件系统信息

文件系统项。

Directory.EnumerateFileSystemEntries

 

文件系统信息 (FileSystemInfo)。

DirectoryInfo.EnumerateFileSystemInfos

文本文件中的行

文件中的行。

File.ReadLines

参考 http://msdn.microsoft.com/zh-cn/library/dd997370.aspx

2.Tuple 类

提供用于创建元组对象的静态方法。

没搞明白用处。以后看懂了再补上。

3.Lazy<T> 类

提供对延迟初始化的支持。

class Program
{
    static void Main(string[] args)
    {
        Lazy<int> lazyInt = new Lazy<int>();
        Console.WriteLine(lazyInt.IsValueCreated);
        lazyInt.Value.ToString();
        Console.WriteLine(lazyInt.IsValueCreated);
    }
}

被延迟加载的对象只在Lazy(Of T).Value 时初始化。

参考 http://msdn.microsoft.com/zh-cn/library/dd642331.aspx

4.并行计算

参考 http://msdn.microsoft.com/zh-cn/library/dd460693.aspx

 

 

5. Task

http://www.cnblogs.com/myshell/archive/2010/03/04/1677908.html

原文地址:https://www.cnblogs.com/yuanhuaming/p/1781384.html