namespace 匿名类型
{
class Program
{
static void Main(string[] args)
{
var s = new { Name = "tom", Age = 10 };
Console.WriteLine(s);
Console.ReadLine();
}
}
}
var s = new { Name = "tom", Age = 10 }; 可以是任意的类型,任意的数量~!爽吧~!
=====================================================================
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 匿名类型
{
class Program
{
static void Main(string[] args)
{
string s = "ajax,javascript,jquery";
string[] ss = s.Split(',');
foreach (var item in ss)
{
Console.WriteLine(item.QuotedStr());
}
Console.ReadLine();
}
}
static class StringExt //注意扩展方法要声明道static中
{
//方法是static 在参数前要加上this
public static string QuotedStr(this string ss)
{
return "【" + ss + "】";
}
}
}