Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# loop through array

//iterate the array
for (int i = 0; i < arr.Length; i++)
{
  // loop ...
}
// or
foreach (var element in arr)
{
  // loop ...
}
Comment

how to loop over array in c#

int[] numbers = new int[] {66,87,34,23,27,4};
foreach(int x in numbers){
	Console.WriteLine(x);
}
Comment

loop through string array c#

 string[] arr = new string[4]; // Initialize.
        arr[0] = "one";               // Element 1.
        arr[1] = "two";               // Element 2.
        arr[2] = "three";             // Element 3.
        arr[3] = "four";              // Element 4.

        // Loop over strings.
        foreach (string s in arr)
        {
            Console.WriteLine(s);
        }
Comment

c# loop string array

//Using Linq to itterate over an array
var strArr = new string[4] {"one", "Two", "Three", "Four"};
Console.WriteLine(strArr.Select((s, i) => $"Item no: {i + 1}, Value: {s}"));
Comment

c# loop array

  Debug.Assert((theData.Length % 3) == 0);  // 'theData' will always be divisible by 3

  for (int i = 0; i < theData.Length; i += 3)
  {
       //grab 3 items at a time and do db insert, 
       // continue until all items are gone..
       string item1 = theData[i+0];
       string item2 = theData[i+1];
       string item3 = theData[i+2];
       // use the items
  }
Comment

c# loop through array

 for (int i = 0; i < theData.Length - 2; i+=3) 
    { 

        // use theData[i], theData[i+1], theData[i+2]

    } 
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity how to get a child from a gameobject 
Csharp :: unity check if other object is colliding 
Csharp :: add item to list c# 
Csharp :: read embedded resource c# xml 
Csharp :: how to convert int to float in c# 
Csharp :: how delete multiple row from relation in laravel 
Csharp :: c# read file from directory 
Csharp :: change button color in script unity 
Csharp :: how to do a messagebox in c# 
Csharp :: WPF Confirmation MessageBox 
Csharp :: o(n*m) 
Csharp :: unity instantiate prefab rotation 
Csharp :: byte to binary c# 
Csharp :: c# datetime add 
Csharp :: add text to combobox c# 
Csharp :: unity raycast 2d 
Csharp :: c# create dynamic json 
Csharp :: how return only value of array in laravel 
Csharp :: how to create a random vector2 in unity 
Csharp :: unity gameobject.find 
Csharp :: c# get all enum values 
Csharp :: httpcontext in .net standard 
Csharp :: c# select first value from list 
Csharp :: wpf messagebox result 
Csharp :: c# edit element in list 
Csharp :: length of a string c# 
Csharp :: datetime default c# 
Csharp :: unity gui text 
Csharp :: wpf toolbar disable overflow 
Csharp :: asp.net core miniprofiler 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =