Skip to content
This repository was archived by the owner on Dec 3, 2025. It is now read-only.
This repository was archived by the owner on Dec 3, 2025. It is now read-only.

Difference in compiler behavior in try.net #175

Closed

Description

@BillWagner

For this code snippet:

object count = "5";

if (count is int number)
    Console.WriteLine(number);
else
    Console.WriteLine($"{number} is not an integer");

The try.net experience compiles and runs, with the message "0 is not an integer".

This is the incorrect behavior. Try the same code locally, and you'll get CS0165 "Use of unassigned local variable 'number'".

Activity

  1. colombod commented on May 9, 2019

    @colombod
    Member

    I get same error CS0165 in both online and compiled scenario
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions