扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:LoveCherry 来源:天极Yesky软件频道 2007年11月2日
关键字:
public class Person { public string username { get; protected set; } public int age { get; set; } public Person() { this.username = "zhuye"; } } Person p = new Person(); //p.username = "aa"; Console.WriteLine(p.username); |
public class Person { public string username { get; set; } public int age { get; set; } public override string ToString() { return string.Format("username:{0} age:{1}", this.username, this.age); } } Person p = new Person() {username = "zhuye", age=26}; Console.WriteLine(p.ToString()); |
public class Person { public string username { get; set; } public int age { get; set; } public override string ToString() { return string.Format("username:{0} age:{1}", this.username, this.age); } } var persons = new List<Person> { new Person {username = "a", age=1}, new Person {username = "b", age=2}}; foreach(var p in persons) Console.WriteLine(p.ToString()); |
var list = new [] { "aa", "bb", "ac" }; var result = Array.FindAll(list, s => (s.IndexOf("a") > -1)); foreach (var v in result) Console.WriteLine(v); |
public delegate int mydg(int a, int b); public static class LambdaTest { public static int oper(this int a, int b, mydg dg) { return dg(a, b); } } Console.WriteLine(1.oper(2, (a, b) => a + b)); Console.WriteLine(2.oper(1, (a, b) => a - b)); |
var persons = new List<Person> { new Person {username = "a", age=19}, new Person {username = "b", age=20}, new Person {username = "a", age=21}, }; var selectperson = from p in persons where p.age >= 20 select p.username.ToUpper(); foreach(var p in selectperson) Console.WriteLine(p); |
var selectperson = persons.Where(p=>p.age>=20).Select(p=>p.username.ToUpper()); |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者