You are previewing C# 4.0 Pocket Reference, 3rd Edition.
O'Reilly logo
C# 4.0 Pocket Reference, 3rd Edition

Book Description

When you're programming C# 4.0 and need a little help, this tightly focused and practical book tells you exactly what you need to know -- without long introductions or bloated examples. It's ideal as a succinct quick reference or as a guide to get you rapidly up to speed if you already know Java, C++, or an earlier version of C#. Written by the authors of the acclaimed C# 4.0 in a Nutshell (O’Reilly), this book covers the entire C# 4.0 language -- without skimping on the details.

Table of Contents

  1. C# 4.0 Pocket Reference
  2. 1. C# 4.0 Pocket Reference
    1. Using Code Examples
    2. How to Contact Us
    3. Safari® Books Online
    4. A First C# Program
      1. Compilation
    5. Syntax
      1. Identifiers and Keywords
        1. Avoiding conflicts
        2. Contextual keywords
      2. Literals, Punctuators, and Operators
      3. Comments
    6. Type Basics
      1. Predefined Type Examples
      2. Custom Type Examples
        1. Members of a type
        2. Symmetry of predefined types and custom types
        3. Constructors and instantiation
        4. Instance versus static members
        5. The public keyword
      3. Conversions
      4. Value Types Versus Reference Types
        1. Value types
        2. Reference types
        3. Null
      5. Predefined Type Taxonomy
    7. Numeric Types
      1. Numeric Literals
        1. Numeric literal type inference
        2. Numeric suffixes
      2. Numeric Conversions
        1. Integral to integral conversions
        2. Real to real conversions
        3. Real to integral conversions
      3. Arithmetic Operators
      4. Increment and Decrement Operators
      5. Specialized Integral Operations
        1. Integral division
        2. Integral overflow
        3. The checked and unchecked operators
        4. Bitwise operators
      6. 8- and 16-Bit Integrals
      7. Special Float and Double Values
      8. double Versus decimal
      9. Real Number Rounding Errors
    8. Boolean Type and Operators
      1. Equality and Comparison Operators
      2. Conditional Operators
    9. Strings and Characters
      1. String Type
        1. String concatenation
        2. String comparisons
        3. Searching within strings
        4. Manipulating strings
    10. Arrays
      1. Default Element Initialization
      2. Multidimensional Arrays
        1. Rectangular arrays
        2. Jagged arrays
      3. Simplified Array Initialization Expressions
    11. Variables and Parameters
      1. The Stack and the Heap
        1. Stack
        2. Heap
      2. Definite Assignment
      3. Default Values
      4. Parameters
        1. Passing arguments by value
        2. The ref modifier
        3. The out modifier
        4. The params modifier
        5. Optional parameters (C# 4.0)
        6. Named arguments (C# 4.0)
      5. var—Implicitly Typed Local Variables
    12. Expressions and Operators
      1. Assignment Expressions
      2. Operator Precedence and Associativity
        1. Precedence
        2. Left-associative operators
        3. Right-associative operators
      3. Operator Table
    13. Statements
      1. Declaration Statements
        1. Local variable scope
      2. Expression Statements
      3. Selection Statements
        1. The if statement
        2. The else clause
        3. Changing the flow of execution with braces
        4. The switch statement
      4. Iteration Statements
        1. while and do-while loops
        2. for loops
        3. foreach loops
      5. Jump Statements
        1. The break statement
        2. The continue statement
        3. The goto statement
        4. The return statement
    14. Namespaces
      1. The using Directive
      2. Rules Within a Namespace
        1. Name scoping
        2. Name hiding
        3. Repeated namespaces
        4. The global:: qualifier
      3. Aliasing Types and Namespaces
    15. Classes
      1. Fields
      2. Methods
        1. Overloading methods
      3. Instance Constructors
        1. Implicit parameterless constructors
        2. Nonpublic constructors
      4. Object Initializers
      5. The this Reference
      6. Properties
        1. Automatic properties
        2. get and set accessibility
      7. Indexers
        1. Implementing an indexer
      8. Constants
      9. Static Constructors
      10. Static Classes
      11. Finalizers
      12. Partial Types and Methods
        1. Partial methods
    16. Inheritance
      1. Polymorphism
      2. Casting and Reference Conversions
        1. Upcasting
        2. Downcasting
        3. The as operator
        4. The is operator
      3. Virtual Function Members
      4. Abstract Classes and Abstract Members
      5. Hiding Inherited Members
      6. Sealing Functions and Classes
      7. The base Keyword
      8. Constructors and Inheritance
        1. Constructor and field initialization order
      9. Overloading and Resolution
    17. The object Type
      1. Boxing and Unboxing
      2. Static and Runtime Type Checking
      3. The GetType Method and typeof Operator
      4. Object Member Listing
      5. Equals, ReferenceEquals, and GetHashCode
      6. The ToString Method
    18. Structs
      1. Struct Construction Semantics
    19. Access Modifiers
      1. Friend Assemblies
      2. Accessibility Capping
    20. Interfaces
      1. Extending an Interface
      2. Explicit Interface Implementation
      3. Implementing Interface Members Virtually
      4. Reimplementing an Interface in a Subclass
    21. Enums
      1. Enum Conversions
      2. Flags Enums
      3. Enum Operators
    22. Nested Types
    23. Generics
      1. Generic Types
      2. Generic Methods
      3. Declaring Type Parameters
      4. typeof and Unbound Generic Types
      5. The default Generic Value
      6. Generic Constraints
      7. Subclassing Generic Types
      8. Self-Referencing Generic Declarations
      9. Static Data
      10. Covariance (C# 4.0)
      11. Contravariance (C# 4.0)
    24. Delegates
      1. Writing Plug-in Methods with Delegates
      2. Multicast Delegates
      3. Instance Versus Static Method Targets
      4. Generic Delegate Types
      5. The Func and Action Delegates
      6. Delegate Compatibility
        1. Return type variance
        2. Parameter variance
        3. Type parameter variance for generic delegates (C# 4.0)
    25. Events
      1. Standard Event Pattern
      2. Event Accessors
    26. Lambda Expressions
      1. Capturing Outer Variables
        1. Capturing iteration variables
    27. Anonymous Methods
    28. try Statements and Exceptions
      1. The catch Clause
      2. The finally Block
        1. The using statement
      3. Throwing Exceptions
        1. Rethrowing an exception
      4. Key Properties of System.Exception
      5. Common Exception Types
    29. Enumeration and Iterators
      1. Enumeration
      2. Collection Initializers
      3. Iterators
      4. Iterator Semantics
        1. Multiple yield statements
        2. yield break
      5. Composing Sequences
    30. Nullable Types
      1. Nullable Basics
        1. Nullable<T> struct
        2. Implicit and explicit nullable conversions
        3. Boxing and unboxing nullable values
      2. Operator Lifting
        1. Equality operators (== and !=)
        2. Relational operators (<, <=, >=, >)
        3. All other operators (+, −, *, /, %, &, |, ^, <<, >>, +, ++, --, !, ~)
        4. Mixing nullable and nonnullable operators
      3. bool? with & and | Operators
      4. Null Coalescing Operator
    31. Operator Overloading
      1. Operator Functions
      2. Overloading Equality and Comparison Operators
      3. Custom Implicit and Explicit Conversions
    32. Extension Methods
      1. Extension Method Chaining
      2. Ambiguity and Resolution
        1. Namespaces
        2. Extension methods versus instance methods
        3. Extension methods versus extension methods
    33. Anonymous Types
    34. LINQ
      1. LINQ Fundamentals
        1. A simple query
        2. Projecting
        3. Take and Skip
        4. Element operators
        5. Aggregation operators
        6. Quantifiers
        7. Set operators
      2. Deferred Execution
      3. Standard Query Operators
      4. Chaining Query Operators
      5. Query Expressions
        1. Query expressions versus fluent queries
      6. The let Keyword
      7. Query Continuations
      8. Multiple Generators
      9. Joining
        1. GroupJoin
      10. Ordering
      11. Grouping
      12. OfType and Cast
    35. Dynamic Binding (C# 4.0)
      1. Static Binding Versus Dynamic Binding
      2. Custom Binding
      3. Language Binding
      4. RuntimeBinderException
      5. Runtime Representation of dynamic
      6. Dynamic Conversions
      7. var Versus dynamic
      8. Dynamic Expressions
      9. Dynamic Member Overload Resolution
      10. Uncallable Functions
    36. Attributes
      1. Attribute Classes
      2. Named and Positional Attribute Parameters
      3. Attribute Targets
      4. Specifying Multiple Attributes
      5. Writing Custom Attributes
      6. Retrieving Attributes at Runtime
    37. Unsafe Code and Pointers
      1. Pointer Basics
      2. Unsafe Code
      3. The fixed Statement
      4. The Pointer-to-Member Operator
      5. Arrays
        1. The stackalloc keyword
        2. Fixed-size buffers
      6. void*
      7. Pointers to Unmanaged Code
    38. Preprocessor Directives
      1. Pragma Warning
    39. XML Documentation
      1. Standard XML Documentation Tags
  3. Index
  4. About the Authors
  5. Copyright