C#中没有像VB with一样的语句,但是我们在定义对象的时候还是可以直接初始化的,类似于VB的with语句。
//对象初始化赋值
Person p = new Person(){Name="Ian", Age=16, City="LS"};
//List初始化赋值
List<string> l = new List<string>(){"Time", "Is", "Infinite"};
//Dictionary 初始化赋值
Dictionary<string, string> UseFor = new Dictionary<string,string>()
{
{"station","站点"},{"city","城市"},{"province","省"}
};