Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# Error "Use of unassigned local variable" #3660

Closed
pawchen opened this issue Jul 9, 2020 · 3 comments
Closed

C# Error "Use of unassigned local variable" #3660

pawchen opened this issue Jul 9, 2020 · 3 comments

Comments

@pawchen
Copy link

pawchen commented Jul 9, 2020

Version Used:
VS2019 16.6.3

Steps to Reproduce:

    class Program
    {
        static Dictionary<string, string> D;

        static void Main(string[] args)
        {
            if (D?.TryGetValue("k", out var value) == true)
            {
                var v = value;
            }
        }
    }

Expected Behavior:

No error.

Actual Behavior:

Error CS0165 Use of unassigned local variable 'value'

@CyrusNajmabadi CyrusNajmabadi transferred this issue from dotnet/roslyn Jul 9, 2020
@CyrusNajmabadi
Copy link
Member

Transfered to C# lang, as this is a language change request. Virtually certain it's a dupe of something that already exists :)

@yaakov-h
Copy link
Member

yaakov-h commented Jul 9, 2020

Duplicate of #3365.

@333fred
Copy link
Member

333fred commented Jul 9, 2020

Closing as a duplicate.

@333fred 333fred closed this as completed Jul 9, 2020
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

No branches or pull requests

4 participants