C# · 12月 20, 2021

[读书笔记]C#学习笔记五: C#3.0自动属性,匿名属性及扩展方法

<p style=”background: gray; color: #ffffff; font-size: 18pt;”>前言

{ {name = { }

Name{; Age{; }

PS: 这里也有一个快捷键: 打出prop 然后点击两下Tab键就可以生成上面的属性了,不过还需手动改值.

Name { ; Age { ; TestPerson( : .Name = }

stringValue = stringValue = }

Main( Person p = Person(, p.Weight = p.Height = Name { ; Age { ; Weight { ; Height { ; Person( Person( name, Person( name, age, Person( name, weight, .Name = .Age = .Weight = .Height = }

Main( Person p = Person() {Name = ,Age = ,Weght = ,Height = Person p2 = Person {Name = ,Height = Name { ; Age { ; Weight { ; Height { ; }

List newNames = List ,, }

Main( person = {Name = ,Age = Console.WriteLine( personCollection = {Name = ,Age = {Name = ,Age = {Name = ,Age = totalAge = ( p totalAge += Console.WriteLine( }

TestStr( TestInt( i, Console.WriteLine(s + Main( s = s.Teststr(); Extensions.TestStr(s); i = i.TestInt( Extensions.TestInt(i, }

Main( Person p = Person {Name = p.Print();ExtensionClass.Print(p); p.Print( Name { ; Print( Console.WriteLine( Pint( Console.WriteLine( Pint( Person p, Console.WriteLine( }

当前命名空间下的扩展方法–>导入命名空间的扩展方法.