Number of references to class variable is incorrect

Brown, Matt 66 Reputation points
2024-07-16T15:32:14.52+00:00

I created a class level variable in the Program.cs file and use it 27 times within that file. I can do a search for the variable name and make sure spelling isn't an issue. If I go look at the number of times the variable has a reference as stated where it is defined, the number is 3. The variable is defined as private string, and I have another variable defined as such at the class level and all of its uses are counted correctly for its reference count.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,879 questions
{count} votes

Accepted answer
  1. Jiale Xue - MSFT 44,841 Reputation points Microsoft Vendor
    2024-07-17T02:14:06.48+00:00

    Hi @Brown, Matt , Welcome to Microsoft Q&A,

    So the issue is the op had defined a local variable with the same name.

    Best Regards,

    Jiale


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Brown, Matt 66 Reputation points
    2024-07-16T19:44:34.9133333+00:00

    The error was I had defined a local variable with the same name.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.