Define it outside the while
:
string cust_num = null;
while ...
and then inside the while set it like this:
cust_num = Console.ReadLine();
because you’re trying to access it after the while:
return cust_num;
More Related Contents:
- I want to insert a record in DB and then need to return a row
- C# compiler error: “not all code paths return a value”
- Return multiple values to a method caller
- Is there a reason for C#’s reuse of the variable in a foreach?
- C# variable scoping: ‘x’ cannot be declared in this scope because it would give a different meaning to ‘x’
- Variable scope confusion in C#
- How to use Global Variables in C#?
- Why aren’t variables declared in “try” in scope in “catch” or “finally”?
- Private inner classes in C# – why aren’t they used more often?
- Why can’t we define a variable inside an if statement?
- variable scope in statement blocks
- TransactionScope With Files In C# [duplicate]
- Why use a public method in an internal class?
- How to trim after 1 letter from space C#? [closed]
- How does the ternary operator work?
- Merging multiple PDFs using iTextSharp in c#.net
- GetFiles with multiple extensions [duplicate]
- Error deploying ClickOnce application – Reference in the manifest does not match the identity of the downloaded assembly
- C# – Cannot implicitly convert type List to List
- How do I accept an array as an ASP.NET MVC controller action parameter?
- How to extract text from MS office documents in C#
- Testing equality of arrays in C#
- Generating random numbers without repeating.C# [duplicate]
- Dynamically Reading COBOL Redefines with C#
- Random errors using wait for element clickable method in Selenium
- ObservableCollection and Item PropertyChanged
- Selenium Webdriver + PhantomJS remains at about:blank for a specific site
- Using .net standard 1.5 lib in .net 4.6.2 misses System.Runtime 4.1.0.0
- Map two lists into a dictionary in C#
- Why remove unused using directives in C#?