Skip to content

Commit 7f3516c

Browse files
committed
add draft post about .NET 10 LTS and C# 14
1 parent d94a234 commit 7f3516c

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

content/2019-12-09-charp-14.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
tags: hardskill, csharp, dotnet
3+
stream: draft
4+
---
5+
6+
# Bem vindo C# 14 & .NET 10 LTS
7+
## Instalando .NET 10.0 no linux via CLI
8+
```sh
9+
curl -fsSL https://builds.dotnet.microsoft.com/dotnet/scripts/v1/dotnet-install.sh | bash /dev/stdin -c 10.0
10+
```
11+
12+
## Sha-bang com C#
13+
```sh
14+
echo "#\!/bin/dotnet
15+
using System;
16+
Console.WriteLine(\"Hello, world\!\");" > script.cs
17+
18+
chmod +x script.cs
19+
./script.cs
20+
```
21+
22+
## File-based apps
23+
```sh
24+
dotnet run app.cs
25+
```
26+
27+
## Null-conditional assignment
28+
Antes do C# 14:
29+
```csharp
30+
if (customer is not null)
31+
{
32+
customer.Order = GetCurrentOrder();
33+
}
34+
```
35+
36+
Depois do C# 14:
37+
```csharp
38+
customer?.Order = GetCurrentOrder();
39+
```
40+
41+
## Membros de extensão
42+
Antes do C# 14:
43+
```csharp
44+
public static class String
45+
{
46+
public static int WordCount(this string str) => str.split([' ', '.', '?'], StringSplitOptions.RemoveEmptyEnties).Length;
47+
}
48+
```
49+
50+
Depois do C# 14:
51+
```csharp
52+
public static class String
53+
{
54+
extension(string str)
55+
{
56+
public int WordCount() => str.split([' ', '.', '?'], StringSplitOptions.RemoveEmptyEnties).Length;
57+
}
58+
}
59+
```
60+
61+
## Referencias
62+
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-14
63+
- https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-10/
64+
- https://devblogs.microsoft.com/dotnet/csharp-exploring-extension-members/
65+
- https://andrewlock.net/exploring-dotnet-10-preview-features-3-csharp-14-extensions-members/
66+
- https://www.reddit.com/r/csharp/comments/1jsuj5n/exploring_the_new_field_keyword_in_c_14_with_net/
67+
- https://www.youtube.com/playlist?list=PLUOequmGnXxMQy-vu2O5VUFAdhu1fE5bY
68+
- https://www.infoworld.com/article/4000493/c-sharp-14-introduces-file-based-apps.html

0 commit comments

Comments
 (0)