Categories Csharp10
Retweets are appreciated ๐
#dotnet #csharp #coding #devcommunity
Constant interpolated
C# 10 allows initializing 'const' strings using string interpolation, but the placeholder must also be a 'const' string.
— Oleg Kyrylchuk (@okyrylchuk) September 9, 2021
The placeholder can't be a numeric constant cause it's converted to string at runtime.
Will you use the feature in your code?#dotnet #coding #devcommunity pic.twitter.com/H52ithdZC4
Extended property
Starting from C# 10, you can reference nested properties or fields within a proper pattern.
— Oleg Kyrylchuk (@okyrylchuk) September 10, 2021
The property pattern becomes more readable and requires fewer curly brackets \U0001f642
What do you think about the feature? #dotnet #coding #devcommunity pic.twitter.com/iHmbdYUAOW
File scoped
C# 10 introduces a new way of namespace declarations - file scoped namespaces.
— Oleg Kyrylchuk (@okyrylchuk) September 11, 2021
However, you cannot declare a nested namespace or a second file-scoped namespace in the same file.
C# continue to rid of curly brackets {\U0001f600}#dotnet #programming #devcommunity pic.twitter.com/docHOfZQYf
Global
C# 10 adds a new modifier to a 'using' directive - 'global'.
— Oleg Kyrylchuk (@okyrylchuk) September 12, 2021
It means that 'using' is applied to all files in the compilation.
All 'global using' directives must be before non-global 'using' directives.
It can be combined with a 'static' modifier#dotnet #coding #devcommunity pic.twitter.com/osr3ZPh5AI