>Hi All,
>
>I have a method that returns a string if there is no file in a directory. I have stepped through this and watched this line get set to an empty string but when it comes back to the calling line of code, it is null. I am missing something and wonder if it is the way I did the while statement. Any ideas appreciated.
>Thanks for the help
>Tim
>
>When the return from PopQueue is set to "" then in my while statement the value of fileName is null. Why would this be?
>
>while ((fileName = this.PopQueue(path, filter)) != "" && llSuccess)
>{
> // Do all my stuff here, process each file returned until no more files are returned.
>}
>}
>
hi Tim,
There's nothing wrong with the while statement. It's just that the debugger upon returning from PopQueue() still shows the old (null) value
My guess is that the assignment hasn't executed yet, so filename is still null
class test
{
static void Main(string[] args)
{
string fileName;
bool success = true;
while ((fileName = PopQueue()) != "" && success) // here it's still null in the debugger - after execution of PopQueue()
{
}
Console.ReadLine();
}
static string PopQueue()
{
return "";
}
}
Gregory