Learning Properties in C# 2005

joe_pool_is

Contributor
Joined
Jan 18, 2004
Messages
507
Location
Longview, TX [USA]
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.
Code:
// ----------------------------------------
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?
 
Back
Top