C# Class Question


Recommended Posts

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 Adventure

here is my code so far

Invatory.cs

using 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.cs

using 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 ??

Link to post
Share on other sites

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..

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...