![Page 1: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/1.jpg)
“Effective C#”
Brendan Duffy
++And a little VB
![Page 2: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/2.jpg)
dotNET solutions
Wagner
• Effective C#• Addison Wesley• 300 pages
![Page 3: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/3.jpg)
dotNET solutions
If you're interested in, or currently working with, .NET and are tempted to skip past this book as Just Another C# Reference Book, think again. Wagner's book is a great resource because it covers concepts which run across the entire .NET Framework regardless of which language you're working with. While this book focuses on C#, VB.NET developers can benefit from some of the text within as well.
Excerpts from Jim Holmes review, Dayton .NET Users Group
![Page 4: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/4.jpg)
dotNET solutions
I also think this book speaks to a wide range of readers. Seasoned developers will blow through this content, fine-tuning their coding methods or starting new ones. …New developers also can greatly benefit from this book by using it to properly form development habits early in their careers.
Excerpts from Jim Holmes review, Dayton .NET Users Group
![Page 5: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/5.jpg)
dotNET solutions
Wagner's writing style is clear and concise. He occasionally comes across as brusque … but those instances are few and far between. The rest of the book's voice is terrific. More important is the weight of Wagner's knowledge and experience. One real drawback is a large number of typographical errors, … I would have expected better proofreaders at AW.
Excerpts from Jim Holmes review, Dayton .NET Users Group
![Page 6: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/6.jpg)
dotNET solutions
The book is well organized into six chapters, each hitting a specific area in C#. Within each chapter, Wagner covers six to ten items, each item focusing on one specific "mini topic," as Wagner calls them. Each item includes code snippets to demonstrate recommended approaches.
Excerpts from Jim Holmes review, Dayton .NET Users Group
![Page 7: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/7.jpg)
dotNET solutions
Balena and Dimauro
• Practical Guidelines and Best Practices for Microsoft Visual Basic and Visual C# Developers
• Microsoft Press• 570 pages
![Page 8: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/8.jpg)
dotNET solutions
This book, which is language agnostic, contains a large number of items, which ranging from a brief few lines to several pages in length. The breadth of the coverage is extensive and allows easy scanning. The guidelines are easy to understand with a limited number that are debateable. Almost all items include a concise paragraph outlining why the practice is recommended. The writing style is clear and avoids the cookbook style, only including code snippets where needed.
![Page 9: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/9.jpg)
dotNET solutions
“Most recommendations are very practical and can easily be applied immediately. In addition many of the suggestions are put in context with a brief discussion over the pros and cons. … The book's tailored towards practicality. It is simply structured, uses basic and direct language and takes clear positions. That makes it easy and fun to read - yet it provides remarkably good information, not firstly on grand concepts, but on many small things that often get overlooked. It's the sort of book you take where ever you go when you just have a couple minutes to read. Open a random page and always get a little ‘aha’”.
Excerpt from an Amazon review
![Page 10: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/10.jpg)
dotNET solutions
Excerpt from an Amazon review
“This is an intermediate level book. It is intended for the programmer who knows the language but is moving up to bigger projects. … Your own experience will likewise lead you to programming methods that may differ from their Guidelines. … On the whole, any programmer reading this book will come away with some guidelines of the ‘Gee, why didn't I think of that’ variety.”
![Page 11: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/11.jpg)
dotNET solutions
Always use _____ instead of accessible data members.
a) Variables
b) Properties
c) Methods
d) Delegates
Effective C#, Wagner, p 1
![Page 12: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/12.jpg)
dotNET solutions
The Option Strict directive.
When should you use Option Strict Off?
Practical Guidelines and Best Practices, Balena & Dimauro, p 10
Projects and Solutions, 23 items
![Page 13: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/13.jpg)
dotNET solutions
Prefer _____ to const.
a) set
b) mutable
c) get
d) readonly
Effective C#, Wagner, p 12
![Page 14: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/14.jpg)
dotNET solutions
Line Wrapping.
What is the shortcut key for toggling word wrapping in VS?
Practical Guidelines and Best Practices, Balena & Dimauro, p 14
Spaces and Indentation, 8 items
![Page 15: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/15.jpg)
dotNET solutions
Prefer the is or as operators to _____ .
a) equivalence
b) assignment
c) casts
d) down casting
Effective C#, Wagner, p 17
![Page 16: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/16.jpg)
dotNET solutions
TODO and HACK comment tokens.
How do you toggle display of these items in the task list window?
Practical Guidelines and Best Practices, Balena & Dimauro, p29
Comments, 19 items
![Page 17: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/17.jpg)
dotNET solutions
Use _____ instead of #if.
a) #define
b) Conditional attributes
c) String formatting
d) Regex expressions
Effective C#, Wagner, p 25
![Page 18: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/18.jpg)
dotNET solutions
CLS compliant assemblies
Does VB play well with this attributte?
Practical Guidelines and Best Practices, Balena & Dimauro, p 33
Assemblies and Resources, 14 items
![Page 19: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/19.jpg)
dotNET solutions
Always provide _____ ( ) .
a) Equals
b) GetHashCode
c) ToString
d) MemberwiseClone
Effective C#, Wagner, p 31
![Page 20: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/20.jpg)
dotNET solutions
First level namespace.
What should you use as a first level namespace?
Practical Guidelines and Best Practices, Balena & Dimauro, p 43
Namespaces, 12 items
![Page 21: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/21.jpg)
dotNET solutions
_____ value and reference types .
a) Convert between
b) Distinguish between
c) Derive from
d) Overload constructors for
Effective C#, Wagner, p 38
![Page 22: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/22.jpg)
dotNET solutions
Nested types.
Should they be public?
Practical Guidelines and Best Practices, Balena & Dimauro, p 53
Types, 24 items
![Page 23: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/23.jpg)
dotNET solutions
Prefer _____ value types.
a) Nullable
b) Transactional
c) Polymorpic Granular
d) Immutable atomic
Effective C#, Wagner, p 44
![Page 24: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/24.jpg)
dotNET solutions
Base classes vs interfaces.
Which should you favour?
Practical Guidelines and Best Practices, Balena & Dimauro, p 59
Inheritance, 21 items
![Page 25: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/25.jpg)
dotNET solutions
Understand the pitfalls of _____ .
a) ToString
b) GetHashCode
c) Equals
d) MemberwiseClone
Effective C#, Wagner, p 63
![Page 26: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/26.jpg)
dotNET solutions
Interface immutability.
Are there exceptions?
Practical Guidelines and Best Practices, Balena & Dimauro, p 77
Interfaces, 19 items
![Page 27: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/27.jpg)
dotNET solutions
Ensure that _____ is a valid state for reference types.
a) 0
b) null
c) NaN
d) Error
Effective C#, Wagner, p 51
![Page 28: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/28.jpg)
dotNET solutions
Equals overload in value types.
Is this a performance issue?
Practical Guidelines and Best Practices, Balena & Dimauro, p 97
Structures, 7 items
![Page 29: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/29.jpg)
dotNET solutions
Prefer _____ loops.
a) do
b) for
c) foreach
d) while
Effective C#, Wagner, p 70
![Page 30: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/30.jpg)
dotNET solutions
Member names in an enum type.
Should they have a common prefix?
Practical Guidelines and Best Practices, Balena & Dimauro, p 102
Enum Types, 13 items
![Page 31: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/31.jpg)
dotNET solutions
Prefer variable _____ to assignment statements.
a) methods
b) properties
c) initializers
d) modifiers
Effective C#, Wagner, p 82
![Page 32: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/32.jpg)
dotNET solutions
Invoking a method through reflection.
What is the most efficient way to achieve this?
Practical Guidelines and Best Practices, Balena & Dimauro, p 114
Attribute Types and Reflection, 12 items
![Page 33: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/33.jpg)
dotNET solutions
Utilize constructor _____ .
a) chaining
b) Return values
c) Default parameters
d) linking
Effective C#, Wagner, p 87
![Page 34: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/34.jpg)
dotNET solutions
Hungarian notation.
What is the real purpose of hungarian notation?
Practical Guidelines and Best Practices, Balena & Dimauro, p 116
Fields and Variables, 27 items
![Page 35: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/35.jpg)
dotNET solutions
Utilize _____ for resource cleanup.
a) destructors
b) dispose
c) using
d) finalizers
Effective C#, Wagner, p 93
![Page 36: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/36.jpg)
dotNET solutions
Properties that return arrays.
How do you make the elements of an array immutable?
Practical Guidelines and Best Practices, Balena & Dimauro, p 136
Properties, 14 items
![Page 37: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/37.jpg)
dotNET solutions
Minimize _____.
a) Garbage
b) Disposes
c) Generations
d) instances
Effective C#, Wagner, p 100
![Page 38: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/38.jpg)
dotNET solutions
Factory method names.
How should you name factory methods?
Practical Guidelines and Best Practices, Balena & Dimauro, p 154
Methods, 35 items
![Page 39: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/39.jpg)
dotNET solutions
Minimize _____.
a) Stack size
b) structs
c) Early-binds
d) boxing
Effective C#, Wagner, p 103
![Page 40: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/40.jpg)
dotNET solutions
Calling virtual methods from inside a constructor.
Will this work?
Practical Guidelines and Best Practices, Balena & Dimauro, p 175
Constructors, 19 items
![Page 41: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/41.jpg)
dotNET solutions
Implement the standard _____ pattern.
a) Dispose
b) Garbage Collection
c) Finalize
d) Resurrection
Effective C#, Wagner, p 109
![Page 42: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/42.jpg)
dotNET solutions
Dispose vs Close method.
When should you use the Close method name instead of Dispose?
Practical Guidelines and Best Practices, Balena & Dimauro, p 180
Dispose and Finalize methods, 11 items
![Page 43: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/43.jpg)
dotNET solutions
Prefer defining and implementing interfaces to _____.
a) inheritance
b) polymorphism
c) encapsulation
d) abstraction
Effective C#, Wagner, p 118
![Page 44: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/44.jpg)
dotNET solutions
Events in serializable classes
Why do you need to Implement ISerializable in this case?
Practical Guidelines and Best Practices, Balena & Dimauro, p 201
Delegate and Events, 23 items
![Page 45: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/45.jpg)
dotNET solutions
Express callbacks with _____ .
a) Unsafe code
b) events
c) Delegates
d) interop
Effective C#, Wagner, p 129
![Page 46: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/46.jpg)
dotNET solutions
Go to keyword.
Where is this OK to use?
Practical Guidelines and Best Practices, Balena & Dimauro, p 214
Execution Flow, 26 items
![Page 47: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/47.jpg)
dotNET solutions
Define outgoing interfaces with _____ .
a) Events
b) delegates
c) MarshallByRef
d) Sinks
Effective C#, Wagner, p 131
![Page 48: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/48.jpg)
dotNET solutions
Rethrowing original exceptions.
How is this done, and where?
Practical Guidelines and Best Practices, Balena & Dimauro, p 230
Exception Handling, 29 items
![Page 49: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/49.jpg)
dotNET solutions
Avoid _____ references to internal class objects.
a) creating
b) returning
c) disposing
d) Calling
Effective C#, Wagner, p 137
![Page 50: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/50.jpg)
dotNET solutions
Conversion of boolean values to integers.
Why should this be avoided?
Practical Guidelines and Best Practices, Balena & Dimauro, p 243
Numeric Types, 17 items
![Page 51: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/51.jpg)
dotNET solutions
Prefer _____ to imperative programming.
a) Procedural
b) Declarative
c) Generic
d) Templated
Effective C#, Wagner, p 142
![Page 52: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/52.jpg)
dotNET solutions
Language-specific string functions. [VB]
Are the any disadvantages to using these?
Practical Guidelines and Best Practices, Balena & Dimauro, p 251
Strings, 25 items
![Page 53: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/53.jpg)
dotNET solutions
Prefer _____ types.
a) Serializable
b) Synchronized
c) Transactional
d) Hydrated
Effective C#, Wagner, p 148
![Page 54: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/54.jpg)
dotNET solutions
Large arrays of boolean values.
What is a more memory-efficient type?
Practical Guidelines and Best Practices, Balena & Dimauro, p 270
Arrays and Collections, 21 items
![Page 55: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/55.jpg)
dotNET solutions
Implement _____ relationships with IComparable and IComparer.
a) ordering
b) predicate
c) logical
d) equivalence
Effective C#, Wagner, p 156
![Page 56: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/56.jpg)
dotNET solutions
Weak reference objects.
How should you use and expose these objects?
Practical Guidelines and Best Practices, Balena & Dimauro, p 288
Memory Usage, 12 items
![Page 57: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/57.jpg)
dotNET solutions
Avoid _____.
a) ISerializable
b) ICloneable
c) IList
d) ISortable
Effective C#, Wagner, p 163
![Page 58: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/58.jpg)
dotNET solutions
DateTime serialization.
What strategies can be used to prevent time-zone shifts?
Practical Guidelines and Best Practices, Balena & Dimauro, p 309
Files, Streams and XML, 14 items
![Page 59: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/59.jpg)
dotNET solutions
Avoid _____ operators.
a) overloaded
b) ternary
c) bitwise
d) conversion
Effective C#, Wagner, p 167
![Page 60: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/60.jpg)
dotNET solutions
Signed interop assembles.
How do you generate a strong-named interop assembly?
Practical Guidelines and Best Practices, Balena & Dimauro, p 314
PInvoke and COM Interop, 19 items
![Page 61: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/61.jpg)
dotNET solutions
Prefer CLS compliant _____.
a) Properties
b) Methods
c) Classes
d) Assemblies
Effective C#, Wagner, p 181
![Page 62: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/62.jpg)
dotNET solutions
Asynchronous delegates.
How are these used?
Practical Guidelines and Best Practices, Balena & Dimauro, p 340
Threading, 23 items
![Page 63: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/63.jpg)
dotNET solutions
Prefer small, simple _____.
a) functions
b) assemblies
c) identifiers
d) comments
Effective C#, Wagner, p 186
![Page 64: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/64.jpg)
dotNET solutions
Global error handlers.
How do you implement these?
Practical Guidelines and Best Practices, Balena & Dimauro, p 367
Windows Forms Applications, 37 items
![Page 65: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/65.jpg)
dotNET solutions
Prefer smaller, cohesive _____.
a) metadata
b) methods
c) assemblies
d) properties
Effective C#, Wagner, p 190
![Page 66: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/66.jpg)
dotNET solutions
Batch commands for SQLServer queries.
How does the SQLDataReader work with a batch?
Practical Guidelines and Best Practices, Balena & Dimauro, p 393
ADO.NET Programming, 47 items
![Page 67: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/67.jpg)
dotNET solutions
Limit _____ of your types.
a) instances
b) lifetime
c) scope
d) visibility
Effective C#, Wagner, p 194
![Page 68: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/68.jpg)
dotNET solutions
Accepting uploaded files from the user.
What do you need to do to have the HTMLInputFile control work as expected?
Practical Guidelines and Best Practices, Balena & Dimauro, p 416
ASP.NET Web Forms Applications, 67 items
![Page 69: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/69.jpg)
dotNET solutions
Create _____ Web APIs.
a) Atomic
b) Granular
c) Large-grain
d) Aggregated
Effective C#, Wagner, p 198
![Page 70: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/70.jpg)
dotNET solutions
Support for proxy servers.
How should you implement this?
Practical Guidelines and Best Practices, Balena & Dimauro, p 468
ASP.NET Web Services, 13 items
![Page 71: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/71.jpg)
dotNET solutions
Use the standard _____ mechanism.
a) exception
b) configuration
c) interop
d) reflection
Effective C#, Wagner, p 213
![Page 72: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/72.jpg)
dotNET solutions
Static members.
Why should you avoid these?
Practical Guidelines and Best Practices, Balena & Dimauro, p 475
Serviced Components, 21 items
![Page 73: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/73.jpg)
dotNET solutions
Utilize and support _____.
a) Validation
b) Standard registry keys
c) Server side cursors
d) Data binding
Effective C#, Wagner, p 217
![Page 74: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/74.jpg)
dotNET solutions
Exchanging data between different time zones.
What is the best way of doing this?
Practical Guidelines and Best Practices, Balena & Dimauro, p 506
Remoting, 20 items
![Page 75: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/75.jpg)
dotNET solutions
Prefer _____ to custom structures.
a) xmldatadocuments
b) xmldocuments
c) datasets
d) classes
Effective C#, Wagner, p 237
![Page 76: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/76.jpg)
dotNET solutions
The AllowPartiallyTrustedCallers attribute.
When should this be used?
Practical Guidelines and Best Practices, Balena & Dimauro, p 510
Security, 27 items
![Page 77: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/77.jpg)
dotNET solutions
Utilize _____ to simplify reflection.
a) dllimport
b) attributes
c) interop
d) lutz
Effective C#, Wagner, p 246
![Page 78: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/78.jpg)
dotNET solutions
Don’t overuse _____.
a) using
b) logging
c) reflection
d) interop
Effective C#, Wagner, p 253
![Page 79: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/79.jpg)
dotNET solutions
Create complete _____ exception classes.
a) Generic, reusable
b) Application specific
c) Demand protected
d) MarshalByRef
Effective C#, Wagner, p 248
![Page 80: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/80.jpg)
dotNET solutions
Prefer the _____ exception guarantee.
a) Focused
b) Weak
c) Global
d) Strong
Effective C#, Wagner, p 265
![Page 81: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/81.jpg)
dotNET solutions
Prefer _____.
a) Unsafe code
b) Safe code
c) interop
d) Pointers
Effective C#, Wagner, p 277
![Page 82: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/82.jpg)
dotNET solutions
C# - new features
• Generics• Nullable Types• Delegate Changes & Anonymous Methods• Accessor Accesibility• Iterators• Static Classes and Static Class Members• Partial Class Definitions• Friend Assemblies• Fixed Size Buffers
![Page 83: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/83.jpg)
dotNET solutions
Generics
• Generic Classclass SortedList<T> : where T:Icomparable<T>{ … }
• Generic Methods void Swap<T>(ref T l, ref T r){
T temp; temp = lhs; lhs = rhs; rhs = temp; } • Generic Interfaces• Generic Delegates
![Page 84: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/84.jpg)
dotNET solutions
Nullable Types
• Used to create value types that can contain an undefined state.int? x = null;
• The HasValue property returns true if the variable is not null
![Page 85: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/85.jpg)
dotNET solutions
Delegate Changes
• You can assign an anonymous method directly to a delegatebutton1.Click += delegate {
MessageBox.Show( "Click!") };
• You can declare a delegate using this simplified syntax: MyDelegate<int> d = fn;
• Delegates now allow – covariant return types– Contravariant parameter types
![Page 86: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/86.jpg)
dotNET solutions
Accessor Accessibility
public string Name
{
get { return name; }
protected set { name = value; }
}
![Page 87: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/87.jpg)
dotNET solutions
Iterators
public class DaysOfTheWeek{ string[] m_Days = {"Su","Mo","Tu”,"We","Th","Fr","Sa"};
public IEnumerator GetEnumerator(){ foreach (string day in m_Days)
yield return day; } }
![Page 88: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/88.jpg)
dotNET solutions
Static Classes & Static Members
• No longer need to use private constructors to prevent instance construction.
![Page 89: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/89.jpg)
dotNET solutions
Partial Class Definitions
• To split a class definition, use the partial keyword modifier public partial class MyClass
{ public void method1() { } }
• For code generators.
• May help where multiple programmers work on a class simultaneously.
![Page 90: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/90.jpg)
dotNET solutions
Friend Assemblies
To expose AssyA to AssyB (only)
• Use the InternalsVisibleTo Attributte
• Must use /out switch on AssyA
• Not transitive or reflective
![Page 91: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/91.jpg)
dotNET solutions
Fixed Size Buffers
• Allows allocation of a fixed buffer on the stack.
public struct MyArray
{
public fixed char pathName[128];
}
• Must appear in an unsafe block
![Page 92: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/92.jpg)
dotNET solutions
VS2005 C# Samples
• Base Class Library
• Data Access
• Web Development
• Windows Forms
• http://msdn.microsoft.com/vs2005
![Page 93: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/93.jpg)
dotNET solutions
Base Class Library
• ACLChange• Compression• Console• DriveInfo• FTP• Generics• Network• RegularExpressions• Stopwatch
![Page 94: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/94.jpg)
dotNET solutions
Data Access• Asynchronous Queries• Attaching a database with your application• Creating and using User Defined Types with SQL Server
2005• DataReader vs. DataSet comparision• DataSet and DataTable Enhancements• Performing Batch Updates and Data Paging• Performing Bulk Updates• Reading and Writing Images from a Database• Using Factory Classes• Using Managed SPs and UDFs with SQL Server 2005• Using Multiple Active Result Sets with SQL Server 2005• Using Notifications with SQL Server 2005• Using the XML data type with SQL Server 2005• XPath and XSLT Transformations Enhancements
![Page 95: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/95.jpg)
dotNET solutions
Web Development
• Caching• DataAccess• DataControls• MasterPages• Membership• MenuAndSiteMapPath• Profiles• Security• TreeView• WebParts
![Page 96: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/96.jpg)
dotNET solutions
Windows Forms• AsynchronousTasks• ClientConfiguration• CreatingMasterDetails• PlayingSounds• UsingBindingNavigator• UsingBindingSource• UsingClickOnce• UsingDataGridView• UsingLayoutPanels• UsingMaskedTextBox• UsingMenusStatusStripsToolStrips• UsingSplitContainer• UsingWebBrowser
![Page 97: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/97.jpg)
dotNET solutions
Access Control List Sample
• The System.Security.AccessControl namespace provides a way to create and modify an ACL.
• ACLChange.exe
![Page 98: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/98.jpg)
dotNET solutions
Compression Sample
The System.IO.Compression namespace
• Allows you to compress and decompress files in the GZip format.
• Compression.exe
![Page 99: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/99.jpg)
dotNET solutions
Console Sample
• Framework 2.0 adds a number of new features.
• ConsoleSample.exe
![Page 100: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/100.jpg)
dotNET solutions
DriveInfo Sample
• Provides an easy way to access the properties of all the drives on a system.
• DriveInfoSample.exe
![Page 101: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/101.jpg)
dotNET solutions
FTP Sample
• The System.Net namespace adds full support for the FTP protocol
• FTPSample.exe
![Page 102: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/102.jpg)
dotNET solutions
Generics Sample
The System.Collections.Generic namespace
• Allows flexible reusable code using generic types.
• Provides generic collection classes for type safe collections.
• GenericsSample.exe
![Page 103: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/103.jpg)
dotNET solutions
NetworkInfo, NetworkChange and Ping Sample
• The new NetworkInfo class provides access to a wealth of network related information
• The NetworkChange class provides notification when the IP address of a network interfaces changes.
• The Ping classes provide a way to determine whether a remote computer is accessible.
• NetworkSample.exe
![Page 104: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/104.jpg)
dotNET solutions
Regular Expressions Sample
• The System.Text.RegularExpressions namespace make it easy to use the regular expression syntax to perform complex find and parse operations on text.
• RegularExpressions.exe
![Page 105: “Effective C#” Brendan Duffy ++ And a little VB. dotNET solutions Wagner Effective C# Addison Wesley 300 pages](https://reader035.vdocuments.us/reader035/viewer/2022062409/56649ef65503460f94c09c38/html5/thumbnails/105.jpg)
dotNET solutions
Stopwatch Sample
• The System.Diagnostics now includes a stopwatch that can be used for timing operations.
• StopwatchSample.exe