Invalid token '=' in class, struct, or interface member declaration, Invalid token '(' in class, struct, or interface member declaration
<p>I want to return a last record stored in database and want to instantiate that returned value to the class ReligionCaste's member pID,
But i have the title error.</p>

<p>My database function is</p>

<pre><code>public int LastEnteredRecord()
    {
        int lastId=0;
        dbConnection = new SqlConnection(connectionString);
        try    //If error in connection opening, throws it.
        {
            dbConnection.Open();
            command.Connection = dbConnection;
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = "dbo.LastRecordEntered";


            try    //if error in query execution, throws it.
            {
                lastId= Convert.ToInt32 ( command.ExecuteScalar());
               // MessageBox.Show("Record Entered with ID:"+lastId .ToString ());
            }
            catch (SqlException ex)
            {
                MessageBox.Show(ex.Message);

            }
            dbConnection.Close();
            dbConnection.Dispose();
        }
        catch (SqlException ex)
        {
            MessageBox.Show(ex.Message);

        }
        return lastId;
    }  
</code></pre>

<p>I want to assign that return value to a class instant the code is</p>

<pre><code>class ReligionCaste
{
    //public int religion_ID, caste_ID;
    public String religion, sect, caste, subCaste;
    public int pID;

    DatabaseHandler.DBCntrlr dbObj = new DatabaseHandler.DBCntrlr();
    pID = dbObj.LastEnteredRecord();

 }
</code></pre>

<p>but it giving the above mentioned error.</p>
