这是C#(或可能是VB.net)的.NET问题,但我试图找出以下声明之间的区别:
string hello = "hello";
Run Code Online (Sandbox Code Playgroud)
与
string hello_alias = @"hello";
Run Code Online (Sandbox Code Playgroud)
在控制台上打印没有区别,长度属性是相同的.
我有一些清单:
List<int> list = new List<int> { 1, 2, 3, 4, 5 };
Run Code Online (Sandbox Code Playgroud)
我想对我列表中的元素应用一些转换.我可以通过两种方式做到这一点:
List<int> list1 = list.Select(x => 2 * x).ToList();
List<int> list2 = list.ConvertAll(x => 2 * x).ToList();
Run Code Online (Sandbox Code Playgroud)
这两种方式有什么区别?