... of Wow! eBook ptg Effective C# 50 Specific Ways to Improve Your C# Second Edition Bill Wagner Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London ... 110 Item 20 : Prefer Immutable Atomic Value Types 114 Chapter 3 Expressing Designs in C# 125 Item 21 : Limit Visibility of Your Types 126 Item 22 : Prefer Defining an...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 2 pptx
... y)); storage.Sort((point1, point2) => (point2.Item1*point2.Item1 + point2.Item2 * point2.Item2).CompareTo( point1.Item1 * point1.Item1 + point1.Item2 * point1.Item2)); return storage; } private ... "SomeSample.Size" is not what you want to display to your users. But that’s what you get when you don’t override ToString() in your classes. You write a class once, bu...
Ngày tải lên: 12/08/2014, 16:21
... are, stop it. Veteran C++ programmers would factor the common algorithms into a private helper method. Stop that, too. When you find that multiple constructors contain the same logic, fac- tor ... logic to initialize static member variables, create a static constructor. Implementing the singleton pattern in C# is the most frequent use of a static constructor. Make your instance const...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 4 pdf
... structure refers to the same array storage (phones) allocated outside the object. Developers can modify your immutable structure through another variable that refers to the same storage. To remove ... meant to store data values, value types are the way to go. The decision to make a value type or a reference type is an important one. It is a far-reaching change to turn a val...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 6 pptx
... Relational Operators. public static bool operator <(Customer left, Customer right) { return left.CompareTo(right) < 0; } public static bool operator <=(Customer left, Customer right) ... Customer to the server after all the fields have been set: // create customer on the client. Customer c2 = new Customer(); // Set local copy c2.Name = dlg.Name; // set the local addr. c2.Shi...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 7 ppt
... an element: 20 called MoveNext Delivered 20 at 1:46:08 PM testing element: 21 testing element: 22 testing element: 23 testing element: 24 testing element: 25 testing element: 26 testing ... void Bar(B2 parm1, B2 parm2 = null) { Console.WriteLine("In D.Bar"); } public void Foo2(IEnumerable<B2> parm) { Console.WriteLine("In D.Foo2"); } } Call Foo2...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 8 pps
... want to bring those dynamic objects back into the static type system used by most of your C# code. That’s going to require either a cast or a conver- sion operation: answer = Add(5, 12. 3); ... much work to do. Implementing dynamic behavior can be a great way to approach some of your programming challenges. When you look at creating dynamic types, your first choice should be...
Ngày tải lên: 12/08/2014, 16:21
Effective C#50 Specific Ways to Improve Your C# 2nd phần 3 pps
... complicated logic to initialize the singleton: public class MySingleton2 { private static readonly MySingleton2 theOneAndOnly; static MySingleton2() { theOneAndOnly = new MySingleton2(); } public ... static constructors are called. And, yes, your static initializers execute before the base class’s static constructor. The CLR calls your static constructor automatically before your t...
Ngày tải lên: 12/08/2014, 20:22