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 :: c# create dynamic object 
Csharp :: unique items in list c# 
Csharp :: How do i destroy a prefab without the error? 
Csharp :: unity spherecast 
Csharp :: c# create a zip files 
Csharp :: if statement swiftui 
Csharp :: unity on inspector change 
Csharp :: C# removing the last value of an array 
Csharp :: .net Core Get File Request 
Csharp :: asp net c# compare date to current 
Csharp :: c# map 
Csharp :: unity movement 
Csharp :: c# compress string 
Csharp :: unity find gameobject 
Csharp :: how to get hours and minutes from second in c# 
Csharp :: how to remove all buttons on a form C# 
Csharp :: if button is pressed unity 
Csharp :: c# list remove item based on property duplicate 
Csharp :: unity always rotating object 
Csharp :: how to convert pdfdocument to binary in c# 
Csharp :: c# String.Concat() 
Csharp :: how to remove vowels from a sttring using regex c# 
Csharp :: c-sharp - get current page url/path/host 
Csharp :: assign color to value in c# 
Csharp :: prevent asp button from postback 
Csharp :: c# add string to array 
Csharp :: c# add multiple items to list 
Csharp :: ajax asp.net core 
Csharp :: unity instantiate prefab 
Csharp :: variable gameobject unity 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =