Eric Gunnerson
Posts: 1006
Nickname: ericgu
Registered: Aug, 2003
|
Eric Gunnerson is a program manager on the Visual C# team
|
|
|
|
Arrays with non-zero upper and lower bounds...
|
Posted: Mar 18, 2004 5:15 PM
|
|
|
This post originated from an RSS feed registered with .NET Buzz
by Eric Gunnerson.
|
Original Post: Arrays with non-zero upper and lower bounds...
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
|
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium
|
|
In the comments to my post on zero and one based arrays, several people mentioned that they wanted to be able to have collections that ran from 4 to 10, or from 1900 to 2004 for years. Consider the following: public class YearClass
{
const int StartDate = 1900;
const int EndDate = 2050;
int[] arr = new int[EndDate - StartDate + 1];
public int this[int num]
{
get { return arr[ num - StartDate]; }
set { arr[num - StartDate] = value; }
}
}
public class Test
{
public static void Main()
{ YearClass yc = new YearClass();
yc[1950] = 5;
}
}
I think that gives you the user model that you want.
Read: Arrays with non-zero upper and lower bounds...
|
|