Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to create some properties in my C# project, but the IDE (Visual Studio 2005 Express) is very upset and is throwing red squiggle lines underneath items everywhere.

 

I realize the calendar class I am creating is probably done somewhere already, but I want to learn how to do some things with C# during my time off from work (where we are stuck using Borland). Right now, I want to find out how to add a property and how to access indexed property values.

// ----------------------------------------
public class Calendoo {
 private string mName = "blank";
 private string[] mMonth = new string[16];
 private bool[] mInUse = new bool[16];
 public string Name {
get { return mName; }
set { mName = value; }
 }
 public string MonthO(int i) {
get { return mMonth[i]; }
set { mMonth[i] = value; }
 }
 public bool UseO(int i) {
get { return mInUse[i]; }
set { mInUse[i] = value; }
 }
}
// ----------------------------------------

 

First off, when I hand type in the get/set values, the IDE throws a red squiggle beneath the { and says ; expected.

 

Second, if I hadn't looked at the examples, I would not have known about the secret "value" variable. What would I modify if I wanted to change that to something else (like val, v, or Fred)?

 

Third, the gets mad when I pass values into it, like (int i). How should this be done?

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.

×
×
  • Create New...