Results 1 to 8 of 8

Thread: Making an object:

Threaded View

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Resolved Making an object:

    Now I am going to start as it looks like Mendhak have done lately....here is the next question.

    I am trying to make a new object of a class. The class uses delegations. The class looks like this:

    Code:
    using System;
    
    namespace Spaceobj {
    
    	public delegate void trackOfDay(int p_iDay);
    
    	public class cClock {
    
    		public cClock(int p_iDay) 
    		{
    			iDay = p_iDay;
    		}
    		
    		public int iDay;
    
    		// Event to tell the planets to move.
    		public event trackOfDay moveAcordingly;
    
    
    		// Angi ny dag
    		public void NyDag(int p_iDay) {
    			iDay = (iDay + 1) % 365;
    
    			moveAcordingly(iDay);
    		}
    	};
    
    }
    But when I simply try to make an object of it, like this:

    Code:
    cClock earthDay = new cClock(1);
    then it compiles fine, but when I run it, then it crashes saying.

    An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll

    Additional information: Object reference not set to an instance of an object.
    Last edited by NoteMe; Nov 22nd, 2004 at 05:06 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width