Examples from Chapter 3 (Types) of Programming C# 8.0 (O'Reilly).
- Example 6. Using static members normally
- Example 7. Using static members without explicit qualification
- Example 8. Copying references
- Example 9. Comparing references
- Example 10. Comparing values
- Example 11. Specifying nullability
- Example 12. Specifying an enabled nullable warning context as the project-wide default
- Example 13. Dereferencing a nullable reference
- Example 14. The null forgiving operator
- Example 15. Nullability and the Try pattern—before nullable reference types
- Example 16. Nullable-aware use of the Try pattern
- Example 17. A nullable attribute
- Example 18. Arrays and nullability
- Example 19. A simple struct
- Example 20. Support custom comparison
- Example 21. Comparing struct instances
- Example 22. A read-only struct
- Example 23. A read-only struct in a read-only property
- Example 25. Error: failing to provide a Uri with its URI
- Example 26. A class with one constructor
- Example 27. Using a constructor
- Example 28. A nonempty zero-argument constructor
- Example 29. Optional chaining of constructors
- Example 30. Chained constructor arguments
- Example 31. Class with static constructor
- Example 32. Significant ordering of static fields
- Example 33. Initialization order
- Example 34. Circular static dependencies
- Example 35. Enabling deconstruction
- Example 36. Using a custom deconstructor
- Example 37. Positional pattern using a custom deconstructor
- Example 38. Positional pattern with explicit type
- Example 39. Passing arguments by reference
- Example 40. Putting an out parameter's result into a new variable
- Example 41. Using out parameter's result in the same expression
- Example 42. Putting an out parameter's result into an existing variable
- Example 43. Discarding an out parameter's result
- Example 44. Calling a method with a ref argument
- Example 45. A large value type
- Example 46. A method with an in parameter
- Example 47. A method with an in parameter
- Example 48. A local ref variable
- Example 49. Valid and invalid uses of ref returns
- Example 50. A method with optional arguments
- Example 51. Omitting one argument
- Example 52. Specifying an argument name
- Example 53. Unclear arguments
- Example 54. Improving clarity by naming arguments
- Example 55. Selective argument naming
- Example 56. Overloaded method
- Example 57. String interpolation
- Example 58. String formatting
- Example 59. Explicitly passing multiple arguments as an array
- Example 60. The params keyword
- Example 61. Local functions
- Example 62. An expression-bodied method
- Example 63. An extension method
- Example 64. Extension method available due to namespace declaration
- Example 65. Extension method available due to using directive
- Example 66. Class with simple property
- Example 67. Expression-bodied get and set
- Example 68. An auto-property
- Example 69. Using a property
- Example 70. Auto-property with private setter
- Example 71. Auto-property with no setter
- Example 72. Initializing an auto-property with no setter
- Example 73. A calculated property
- Example 74. An expression-bodied read-only property
- Example 75. A property using a mutable value type
- Example 76. Error: cannot modify a property of a value type property
- Example 77. Replacing a property with methods
- Example 78. A property returning a reference
- Example 79. Making the copy explicit
- Example 80. Making the reference explicit
- Example 81. Using an indexer
- Example 82. Class with indexer
- Example 83. Null conditional index access
- Example 84. Code equivalent to null-conditional index access
- Example 85. Using an object initializer
- Example 86. Using a constructor and an object initializer
- Example 87. Using an indexer in an object initializer
- Example 88. Implementing the + operator
- Example 89. Supporting other operand types
- Example 90. Conversion operators
- Example 91. Using explicit conversion operators
- Example 93. An interface
- Example 94. Implementing an interface
- Example 95. Explicit implementation of an interface member
- Example 96. An interface with a default property implementation
- Example 97. An interface with a const and a nested type