I’m trying to get the variable result from a foreach in my main method. The code looks like this:
static void Main(string[] args)
{
ArrayList lines = GetLines("test.txt", "8394", true);
foreach (string s in lines)
{
string result = s;
}
Console.WriteLine(result);
}
As you can see it returns an error because I cannot access the variable outside of the foreach.
How do I access it?
I cannot understand what do you want to achieve… but the code should be this:
I think you want do to something like this: