Effective C#50 Specific Ways to Improve Your C# Second Edition phần 1 ppt
... Types 11 0 Item 20: Prefer Immutable Atomic Value Types 11 4 Chapter 3 Expressing Designs in C# 12 5 Item 21: Limit Visibility of Your Types 12 6 Item 22: Prefer Defining and Implementing Interfaces to ... this[int x, int y] { Item 1: Use Properties Instead of Accessible Data Members ❘ 5 From the Library of Wow! eBook ptg Effective C# 50 Specific Ways to Improve Your...
Ngày tải lên: 12/08/2014, 16:21
... 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 static IEnumerable<Tuple<int, ... { Customer c = arg as Customer; if (c == null) return arg.ToString(); return string.Format("{0,50}, {1, 15}, {2 ,10 :C}", c.Name, c.Contact...
Ngày tải lên: 12/08/2014, 16:21
... helper method. Stop that, too. When you find that multiple constructors contain the same logic, fac- tor that logic into a common constructor instead. You’ll get the benefits of Item 14 : Minimize ... 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 co...
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
... "", "Anytown", "IL", 611 11) ; // To change, re-initialize: a2 = new Address2(a1.Line1, a1.Line2, "Ann Arbor", "MI", 4 810 3); The value of a1 is in one of ... have performed 10 1 allocations—and 10 1 allo- cations take more time than 1 allocation. Allocating a large number of Item 18 : Distinguish Between Value Types and Reference Ty...
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) ... (!(obj is Customer)) throw new ArgumentException( "Argument is not a Customer", "obj"); Customer otherCustomer = (Customer)obj; return this.CompareTo(otherCustomer); } #en...
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
... ptg testing element: 11 testing element: 12 testing element: 13 testing element: 14 testing element: 15 testing element: 16 testing element: 17 testing element: 18 testing element: 19 testing ... element: 10 projecting an element: 10 testing element: 11 testing element: 12 testing element: 13 testing element: 14 testing element: 15 testing element: 16 testing...
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); ... AddExpressionWithConversion <T1, T2, TResult>(T1 left, T2 right) { var leftOperand = Expression.Parameter(typeof(T1), "left"); Expression convertedLeft = leftOperand; if (...
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
... 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 type is first ... complicated logic to initialize the singleton: public class MySingleton2 { private static readonly MySingleton2 theOneAndOnly; static MySingleton2() { theOneAndOnly = new MySingleton2...
Ngày tải lên: 12/08/2014, 20:22