954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to output a value in array.

Help please I am trying to output a value of an array, for example I want to output 7. How do I do it? Here's the code:

{
	class Program
	{
		public static void Main(string[] args)
		{
			double [] kush = new double [2] {5.2,7};
			
			Console.WriteLine(kush[2]);
			
			
			
			
			Console.ReadKey(true);
		}
	}
}


I can't seem to get this working, what is my mistake ???

Lightning03
Junior Poster in Training
92 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

Arrays are numbered from zero up, so your line 6 creates an array with elements [0] and [1].

That should be enough for you to fix your problem.

Momerath
Nearly a Senior Poster
3,384 posts since Aug 2010
Reputation Points: 1,232
Solved Threads: 558
 

Arrays are numbered from zero up, so your line 6 creates an array with elements [0] and [1].

That should be enough for you to fix your problem.


oh thanks and sorry for such a stupid question I thought I need to add an additional syntax for it but, oh well thank you very much!

Lightning03
Junior Poster in Training
92 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: