Results 1 to 8 of 8

Thread: [Resolved] An Array of Classes?

Threaded View

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] An Array of Classes?

    I'm new to C#. In fact, I've only been screwing around with it for a few hours.

    I'm trying to make an array of classes, but I can't seem to get it right. Code is:

    Code:
    class CMovieList {
        private string strMovieName;
        private double dAmountMade;
    
        public void setValues(string m, double a) {
            strMovieName = m;
            dAmountMade = a;
        }
    
        public string getMovie() {
            return strMovieName;
        }
    
        public double getAmount() {
            return dAmountMade;
        }
    }
    
    class Class1 {
        static void Main(string[] args) {
    
            CMovieList[] cMovies = new CMovieList[1];
    
            cMovies[0].setValues("Movie Name", 120000.0);
            Console.WriteLine("The movie is: " + cMovies[0].getMovie());
        }
    }
    It compiles, but bombs out when it hits a line that accesses the object.
    Last edited by The Hobo; Sep 12th, 2003 at 11:34 AM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

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