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 :: replace text c# file 
Csharp :: how to find the mouse position unity 
Csharp :: unity look at 2d 
Csharp :: bin/bash bad interpreter 
Csharp :: byte array to hex c# 
Csharp :: unity spawn object at position 
Csharp :: check if gameobject exists unity 
Csharp :: how to reference scripts in other scenes unity 
Csharp :: c# main method 
Csharp :: wpf choose file dialog 
Csharp :: load scene unity 
Csharp :: compute months c# 
Csharp :: c# json to dictionary 
Csharp :: OnCollision update 
Csharp :: how to make a button open window in wpf 
Csharp :: c# quit 
Csharp :: contains with ignore case c# 
Csharp :: Set value into lookup field in console app using dynamic CRM 365 
Csharp :: how to insert qoutation marks into string c# 
Csharp :: wpf load file content 
Csharp :: winforms messagebox with button 
Csharp :: unity check if audio playing 
Csharp :: getset c# 
Csharp :: asp.net throw unauthorized exception 
Csharp :: c# image to byte array 
Csharp :: c# get files of type in directory 
Csharp :: SIMPLE HTTP REQUEST C# 
Csharp :: unity agent bake not derecting mesh 
Csharp :: lump in neck under jaw 
Csharp :: how to reference function in unity 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =