Type of issue
Missing information
Description
Hello,
I am working my way through some of the resources provided through Microsoft Learn, and noticed a small error in the following code under Enum Matching section of the Pattern Matching - A Tour of C# module:
currentBalance = 0.0;
foreach (var transaction in TransactionRecords(bankRecords))
{
if (transaction.type == TransactionType.Deposit)
currentBalance += transaction.amount;
else if (transaction.type == TransactionType.Withdrawal)
currentBalance -= transaction.amount;
Console.WriteLine($"{transaction.type} => Parsed Amount: {transaction.amount}, New Balance: {currentBalance}");
}
currentBalance should be preceded with the double value type. Otherwise, the code won't compile.
I hope this is useful, and thank you for providing these resources!
Best,
Matt
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/tutorials/pattern-matching
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/tour-of-csharp/tutorials/pattern-matching.md
Document Version Independent Id
d68419a1-0819-2456-ef95-bfa0a05ec55a
Platform Id
dafef79e-b177-be72-40ff-77db2c38557f
Article author
@BillWagner
Metadata
- ID: cc9b5079-735d-15fc-f5f5-eca009731538
- PlatformId: dafef79e-b177-be72-40ff-77db2c38557f
- Service: dotnet-csharp
- Sub-service: get-started
Related Issues
Type of issue
Missing information
Description
Hello,
I am working my way through some of the resources provided through Microsoft Learn, and noticed a small error in the following code under
Enum Matchingsection of thePattern Matching - A Tour of C#module:currentBalanceshould be preceded with thedoublevalue type. Otherwise, the code won't compile.I hope this is useful, and thank you for providing these resources!
Best,
Matt
Page URL
https://learn.microsoft.com/en-us/dotnet/csharp/tour-of-csharp/tutorials/pattern-matching
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/tour-of-csharp/tutorials/pattern-matching.md
Document Version Independent Id
d68419a1-0819-2456-ef95-bfa0a05ec55a
Platform Id
dafef79e-b177-be72-40ff-77db2c38557f
Article author
@BillWagner
Metadata
Related Issues