Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why a string comes back as null
Message
 
To
02/12/2008 19:40:14
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP SP2
Application:
Desktop
Miscellaneous
Thread ID:
01365266
Message ID:
01365355
Views:
12
>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.
>}
>

What's fileName set to initially?

Actually, my initial thought when I saw this code was, "that actually works?!" I tried out a simpler version of it, and it seems to work OK (I removed the code which accesses the filesystem - it just appends a character to a test string. Still, it might be because of the evaluation order of things. You could try moving the fileName assignment above the while (then duplicating it inside of the while after your // Do all my stuff code has run) to see if that's the case.
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform