0
  1. Trang chủ >
  2. Công Nghệ Thông Tin >
  3. Kỹ thuật lập trình >

Effective C#50 Specific Ways to Improve Your C# 2nd phần 2 ppsx

Effective C#50 Specific Ways to Improve Your C# Second Edition phần 1 ppt

Effective C#50 Specific Ways to Improve Your C# Second Edition phần 1 ppt

... of Wow! eBookptg Effective C# 50 Specific Ways to Improve Your C# Second EditionBill WagnerUpper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London ... 110Item 20 : Prefer Immutable Atomic Value Types 114Chapter 3 Expressing Designs in C# 125 Item 21 : Limit Visibility of Your Types 126 Item 22 : Prefer Defining and Implementing Interfaces to Inheritance ... Members 1Item 2: Prefer readonly to const 8Item 3: Prefer the is or as Operators to Casts 12 Item 4: Use Conditional Attributes Instead of #if 20 Item 5: Always Provide ToString() 28 Item 6: Understand...
  • 35
  • 345
  • 1
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 2 pptx

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, but your clients use it many times. ... Object.ToString() should return the textual representation most likely to be used by clients of that class. In the Customer example, that’s the name:Item 5: Always Provide ToString() ❘ 29 From...
  • 34
  • 373
  • 0
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 3 docx

Effective C#50 Specific Ways to Improve Your C# Second Edition phần 3 docx

... 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 constructor ... natural to reach for the most famil-iar tools at your disposal. However, those tools might not be the best tools. When you find yourself writing any form of a looping construct, ask your- self...
  • 34
  • 349
  • 0
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 4 pdf

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 value type into a class ... copy should be made in all con-structors whenever your immutable type contains a mutable reference type:Item 20 : Prefer Immutable Atomic Value Types ❘ 121 From the Library of Wow! eBookptgor...
  • 34
  • 436
  • 0
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 6 pptx

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.ShippingAddr ... (!(obj is Customer)) throw new ArgumentException("Argument is not a Customer", "obj"); Customer otherCustomer = (Customer)obj; return this.CompareTo(otherCustomer);} #endregion//...
  • 34
  • 369
  • 0
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 7 ppt

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 in a ... D.Foo2"); }}Call Foo2 in a manner similar to before:var sequence = new List<D2> { new D2(), new D2() }; var obj2 = new D();obj2.Foo2(sequence);What do you suppose gets printed this...
  • 34
  • 314
  • 0
Effective C#50 Specific Ways to Improve Your C# Second Edition phần 8 pps

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); ... costs greater.Item 42: Understand How to Make Use of the Expression API.NET has had APIs that enable you to reflect on types or to create code at runtime. The ability to examine code or create ... 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 to derive...
  • 34
  • 380
  • 0
Effective C#50 Specific Ways to Improve Your C# 2nd phần 3 pps

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 type is first ... has not been finalized, it moves to generation 2. In generation 2, an object lives for an extra 100 GC cycles until the next generation 2 collection.Figure 2. 2 This sequence shows the effect...
  • 34
  • 274
  • 0

Xem thêm

Từ khóa: Nghiên cứu tổ hợp chất chỉ điểm sinh học vWF, VCAM 1, MCP 1, d dimer trong chẩn đoán và tiên lượng nhồi máu não cấpNghiên cứu tổ chức chạy tàu hàng cố định theo thời gian trên đường sắt việt namGiáo án Sinh học 11 bài 13: Thực hành phát hiện diệp lục và carôtenôitGiáo án Sinh học 11 bài 13: Thực hành phát hiện diệp lục và carôtenôitĐỒ ÁN NGHIÊN CỨU CÔNG NGHỆ KẾT NỐI VÔ TUYẾN CỰ LY XA, CÔNG SUẤT THẤP LPWANPhát triển mạng lưới kinh doanh nước sạch tại công ty TNHH một thành viên kinh doanh nước sạch quảng ninhNghiên cứu, xây dựng phần mềm smartscan và ứng dụng trong bảo vệ mạng máy tính chuyên dùngNghiên cứu tổng hợp các oxit hỗn hợp kích thƣớc nanomet ce 0 75 zr0 25o2 , ce 0 5 zr0 5o2 và khảo sát hoạt tính quang xúc tác của chúngNghiên cứu khả năng đo năng lượng điện bằng hệ thu thập dữ liệu 16 kênh DEWE 5000Tìm hiểu công cụ đánh giá hệ thống đảm bảo an toàn hệ thống thông tinTổ chức và hoạt động của Phòng Tư pháp từ thực tiễn tỉnh Phú Thọ (Luận văn thạc sĩ)BT Tieng anh 6 UNIT 2Giáo án Sinh học 11 bài 15: Tiêu hóa ở động vậtGiáo án Sinh học 11 bài 15: Tiêu hóa ở động vậtNguyên tắc phân hóa trách nhiệm hình sự đối với người dưới 18 tuổi phạm tội trong pháp luật hình sự Việt Nam (Luận văn thạc sĩ)Giáo án Sinh học 11 bài 14: Thực hành phát hiện hô hấp ở thực vậtGiáo án Sinh học 11 bài 14: Thực hành phát hiện hô hấp ở thực vậtBÀI HOÀN CHỈNH TỔNG QUAN VỀ MẠNG XÃ HỘIMÔN TRUYỀN THÔNG MARKETING TÍCH HỢPTÁI CHẾ NHỰA VÀ QUẢN LÝ CHẤT THẢI Ở HOA KỲ