Imagine your code failed on dr= cmd.....

What would the value of author be?

scott

-----Original Message-----
From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf Of
Curtis Koppang
Sent: Friday, April 19, 2002 9:01 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET] Use of unassigned local variable


I get the "use of unassigned local variable 'author'" error on the
following line of code...

    try
    {
         cn.Open();
         dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
         author = new Author(dr);
    }
    finally
    {
  cn.Close();
    }

    return author;

But not on the following code.

    cn.Open();
    dr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
    author = new Author(dr);
    cn.Close();

    return author;

Why would the two be considered different?

Tx,
curt

You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to