namespace Events { public delegate void ReaderRetreivedEvent(); class BankAccounts { public event ReaderRetreivedEvent ReaderRetreived; private Exception _oException = null; public Exception oException { get { return _oException; } } public SqlDataReader GetReader(string sQuery) { SqlConnection oConn = _ConnectToDb(); // Not included here for brevity SqlCommand oCommand = new SqlCommand(); SqlDataReader oReader = null; oCommand.CommandText = sQuery; oCommand.Connection = oConn; try { oReader = oCommand.ExecuteReader(); } catch (SqlException e) { _oException = e; } if (_oException == null) { ReaderRetreived(); } return oReader; } } }I'm trying to test it like this:
class Program { static SqlDataReader oReader = null; static void Main(string[] args) { BankAccounts oBank = new BankAccounts(); oReader = oBank.GetReader("select * from registers"); oBank.ReaderRetreived += new ReaderRetreivedEvent(ReaderRetreived); // COMPILE ERROR HERE } private void ReaderRetreived() { while (oReader.Read()) { // Some code here } } }I'm getting a compile time error