One dimensional array example

One dimensional array example

Array is collection of similar types. Index of array starts with zero. Here are and example of an array in dot net.

[] one dimensional array.

One Dimensional Array

Example uses array of integers.

using System;
namespace Csharp.RandomExample
class Program
static void Main(string[] args)
int[] arrayOfInteger = new int[] { 12, 4, 5, 6, 78, 98, 7 };
int length = arrayOfInteger.Length;
for (int index = 0; index < length; index++)
Console.WriteLine("Array element number {0} contains {1} number.", index, arrayOfInteger[index]);

[] example of one dimensional array. Program example uses array of integer which is one dimensional array.

Namespace Csharp.RandomExample
Class Program
Private Shared Sub Main(args As String())
Dim arrayOfInteger As Integer() = New Integer() {12, 4, 5, 6, 78, 98, _
Dim length As Integer = arrayOfInteger.Length
For index As Integer = 0 To length - 1
Console.WriteLine("Array element number {0} contains {1} number.", index, arrayOfInteger(index))
End Sub
End Class
End Namespace
Array element number 0 contains 12 number.
Array element number 1 contains 4 number.
Array element number 2 contains 5 number.
Array element number 3 contains 6 number.
Array element number 4 contains 78 number.
Array element number 5 contains 98 number.
Array element number 6 contains 7 number.


Linq Convert String Array To Int Arrayc# arraylistC# foreach loopHow To Declare and access array of string in C#DateTimeTryParse using C# and exampleC# Get Random Item From List ( Example.C# looping through arrayRead Text File in ( or delete file file on Server and codeASP net Write Text On Image and programHow to select multiple columns in Linq- code


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.