4. Readonly Struct
• C# 7.X Struct set as readonly
• C# 8.0 Struct member set as readonly
C#7.X
C#8.0
5. Default interface methods
We know about Interfaces:
1 Only contains declarations of methods,
properties, indexers, and events
2
Interface cannot include private,
protected, or internal members
3 Interface cannot contain fields
4
By default, all the members are public. C#
will give a compile-time error if used
‘public’ keyword explicitly.
10. Switch expressions (cont.)
=>
• Variable comes before the switch keyword
• The case and : elements are replaced with =>
• default case is replaced with a _ discard
• bodies are expressions, not statements
15. Indices and ranges
• array[2]
• array[array.length-2]
• List().GetRange(2,3)
• The last word is {words[^1]}
• words[1..4]
• Start from end words[^2..^0]
17. Nullable reference types
• C# is a strongly-typed language
• Declare the type of a variable
• Value type: integer, float, decimal, text, etc.
• Reference type: string, class, interface, object