BlackStone Posted August 20, 2004 Posted August 20, 2004 When I try to do test for null, I get a "Use of unassigned local variable 'anInstance'". How do I test for null then?? _ MyClass anInstance; if (anInstance == null) { Console.WriteLine("The evaluation worked."); } Quote "For every complex problem, there is a solution that is simple, neat, and wrong." - H. L. Mencken
Administrators PlausiblyDamp Posted August 20, 2004 Administrators Posted August 20, 2004 MyClass anInstance = null; if (anInstance == null) { Console.WriteLine("The evaluation worked."); } As long as you assign something to it (even null) the compiler is happy. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.