Skip to content

Type Checking and Casting in C#: move to .NET 10 - #2307

Open
vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/73003-type-checking-type-casting-csharp
Open

vladimir-pecanac-main wants to merge 1 commit into
CodeMazeBlog:mainfrom
vladimir-pecanac-main:seo/73003-type-checking-type-casting-csharp

Conversation

@vladimir-pecanac-main

Copy link
Copy Markdown
Collaborator

Retargets both projects in csharp-basic-topics/TypeCheckingAndCastingInCSharp to net10.0 and updates the test packages (Microsoft.NET.Test.Sdk 18.11.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.1, coverlet.collector 10.1.0). The is-operator test now declares its values as object, which removes the CS0183 and CS0184 warnings and matches the updated article snippet, and two tests are added: is against GetType() on a Horse held in an Animal variable, and a long.MaxValue cast to int that gives -1 unchecked and throws OverflowException checked. Build has 0 warnings and all 19 tests pass.

… add tests

Both projects move to net10.0 and the test packages to Microsoft.NET.Test.Sdk 18.11.0, xunit 2.9.3, xunit.runner.visualstudio 4.0.1 and coverlet.collector 10.1.0. The is-operator test declares its values as object, which removes the CS0183 and CS0184 warnings. Two tests added: is against GetType() on a derived instance, and an overflowing long cast in unchecked and checked contexts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant