C# Arrays Tutorial with Examples
Today, We want to share with you C# Arrays Tutorial with Examples.
In this post we will show you dynamic array in c#, hear for c# array of objects we will give you demo and example for implement.
In this post, we will learn about c# string array initialization with an example.
Arrays In C#
In this post,we will learn Arrays In C# with an example.
Now in this post, I will explain Arrays In C# with appropriate example.
Array is collection of homogeneous(similar type) elements, which implies we only can store the same type of element in an array. For example if I create array of string type, I only can store string value in it.
Types of Array in C#.Net
Arrays can be divided into the following four categories.
Create array of string type.(Single-dimensional arrays)
[php]
string[] EmployeeName = new string[3];
EmployeeName [0] = “Jaydeep”;
EmployeeName [1] = “Gondaliya”;
EmployeeName [2] = “Krunal”;
[/php]
In the above code I have created array of string type and assigned capacity 3. It means I can only store 3 string values. Array works on index based, and indexing starts with 0. First element keeps at index 0.
Retrieve data from an Array.
we can retrive array data using foreach loop.
[php]
string[] EmployeeName = new string[3];
EmployeeName [0] = “Jaydeep”;
EmployeeName [1] = “Astha”;
EmployeeName [2] = “Krunal”;
foreach(int emp in EmployeeName)
{
Console.WriteLine(emp);
}
[/php]
Read :
Summary
You can also read about AngularJS, ASP.NET, VueJs, PHP.
I hope you get an idea about Arrays In C# demo.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
We hope This Post can help you…….Good Luck!.