Click here to Skip to main content
15,917,731 members
Home / Discussions / C#
   

C#

 
AnswerRe: Voice chat Pin
RizwanSharp25-Mar-06 4:29
RizwanSharp25-Mar-06 4:29 
GeneralRe: Voice chat Pin
deepthi wilson26-Mar-06 17:06
deepthi wilson26-Mar-06 17:06 
QuestionHow do I list Drive informations of a remote computer Pin
deepthi wilson24-Mar-06 23:39
deepthi wilson24-Mar-06 23:39 
AnswerRe: How do I list Drive informations of a remote computer Pin
RizwanSharp25-Mar-06 3:29
RizwanSharp25-Mar-06 3:29 
QuestionArrays in a class definition Pin
IceWater4224-Mar-06 23:28
IceWater4224-Mar-06 23:28 
AnswerRe: Arrays in a class definition Pin
Guffa25-Mar-06 0:21
Guffa25-Mar-06 0:21 
GeneralRe: Arrays in a class definition Pin
IceWater4225-Mar-06 4:30
IceWater4225-Mar-06 4:30 
GeneralRe: Arrays in a class definition Pin
kasik25-Mar-06 6:37
kasik25-Mar-06 6:37 
You have two arrays, like Guffa said, number and _number and you dont assign anything to either of them. The fact that they have the same name, give or take an underscore, means nothing, they are completely different variables that are in no way related to each other.
Your code crashes on x.number[1] because you havent initialised number to anything, and so it is currently null. So trying to access the second value of it will crash because there is no second element. Try the following code, is should work...
class myClass
{
	// fields
	private string _name;
	private double[] _number = new double[5];
	
	// properties
	public string name
	{
		get { return _name; }
		set { _name = value; }
	}
	
	public double[] number
	{
		get { return _number; }
		set { _number = value; }
	}
	
	public double this[int index]
	{
		get { return _number[index]; }
		set { _number[index] = value; }
	}
	
	// Default constructor:
	public myClass()
	{
		name = "";
		_number[0] = 0;
		_number[1] = 0;
		_number[2] = 0;
		_number[3] = 0;
		_number[4] = 0;
	}
	// Clear Numbers
	public void ClearNumbers()
	{
		_number[0] = 0;
		_number[1] = 0;
		_number[2] = 0;
		_number[3] = 0;
		_number[4] = 0;
	}
}
Hope that helps Smile | :)

Cheers,
Will H
GeneralRe: Arrays in a class definition Pin
IceWater426-Apr-06 19:18
IceWater426-Apr-06 19:18 
GeneralRe: Arrays in a class definition Pin
kasik7-Apr-06 5:51
kasik7-Apr-06 5:51 
QuestionDial a number using C# Pin
mrkeivan24-Mar-06 23:12
mrkeivan24-Mar-06 23:12 
QuestionDirectSound & Speakers Pin
Superwill24-Mar-06 23:00
Superwill24-Mar-06 23:00 
Questionhow to use constructors?? Pin
abdelhameed8124-Mar-06 22:56
abdelhameed8124-Mar-06 22:56 
AnswerRe: how to use constructors?? Pin
Colin Angus Mackay25-Mar-06 0:06
Colin Angus Mackay25-Mar-06 0:06 
GeneralRe: how to use constructors?? Pin
Guffa25-Mar-06 0:58
Guffa25-Mar-06 0:58 
AnswerRe: how to use constructors?? Pin
Guffa25-Mar-06 0:55
Guffa25-Mar-06 0:55 
QuestionTAPI Pin
hafz24-Mar-06 21:39
hafz24-Mar-06 21:39 
Answercan you help me out Pin
mrkeivan25-Mar-06 0:34
mrkeivan25-Mar-06 0:34 
GeneralRe: can you help me out Pin
RizwanSharp25-Mar-06 3:09
RizwanSharp25-Mar-06 3:09 
GeneralRe: can you help me out Pin
cfsego7-May-06 21:05
cfsego7-May-06 21:05 
GeneralRe: can you help me out Pin
mrkeivan8-May-06 3:58
mrkeivan8-May-06 3:58 
QuestionCan We detect Sql Servers on Network using c# Pin
Jax_qqq24-Mar-06 19:37
Jax_qqq24-Mar-06 19:37 
QuestionHow to change textBox contents using ActiveX Pin
wajih2k24-Mar-06 19:04
wajih2k24-Mar-06 19:04 
QuestionDll's Pin
Navaneeth.K.N24-Mar-06 18:58
Navaneeth.K.N24-Mar-06 18:58 
AnswerRe: Dll's Pin
HakunaMatada24-Mar-06 21:56
HakunaMatada24-Mar-06 21:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.