4
在下面的代碼中,爲什麼變量c2和c3是不同的匿名類型?c#匿名類型問題
在此先感謝您的任何建議和......乾杯!
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
var c1 = new Customer { Name = "Mark", Country = "USA" };
var c2 = new { c1.Name, c1.Country }; //"<>f__AnonymousType0`2"
var c3 = new { c1.Country, c1.Name }; //"<>f__AnonymousType1`2"
}
}
public class Customer
{
public string Name { get; set; }
public string Country { get; set; }
}
}