iccaros Posted June 23, 2006 Report Share Posted June 23, 2006 ok I have a program I am creating and I added a class called invatory, I get this error when I try to use the class Error 1 'cSharp_Adventure.Invatory.Invatory()' is inaccessible due to its protection level C:\Documents and Settings\huskeyw\My Documents\Visual Studio 2005\Projects\cSharp Adventure\cSharp Adventure\Program.cs 18 33 cSharp Adventurehere is my code so farInvatory.csusing System;using System.Collections.Generic;using System.Text;namespace cSharp_Adventure{ public class Invatory { public string[] invatory; Invatory() { invatory = new string[5] {"Empty","Empty","Empty","Empty","Empty"}; } public void setInvatory(int itemNumber, string item) { invatory[itemNumber] = item; } }}form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace cSharp_Adventure{ public partial class MainForm : Form { //Decare runtime varables Invatory invatory = new Invatory(); //End runtime varables public MainForm() { InitializeComponent(); } private void ObjectWord_TextChanged(object sender, EventArgs e) { } private void CommandWord_TextChanged(object sender, EventArgs e) { } }any help as to why a public class is protected ?? Quote Link to post Share on other sites
jcl Posted June 23, 2006 Report Share Posted June 23, 2006 It's the constructor. You don't have an access qualifier on it. Quote Link to post Share on other sites
iccaros Posted June 23, 2006 Author Report Share Posted June 23, 2006 Thanks, now I feel dumb... I had thought about it, but for some reason I thought construtors did not need one as they have no return type.. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.