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 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 set dropdown value 
Csharp :: how to display doubles with trailing zeros in c# 
Csharp :: how to get parent gameobject in unity 
Csharp :: how to make font c# 
Csharp :: c# foreach dictionary 
Csharp :: loading screen unity 
Csharp :: how to split concat string c# 
Csharp :: unity joystick movement 2d 
Csharp :: difference between iqueryable and ienumerable c# 
Csharp :: how to make a global string c# 
Csharp :: cannot convert from string to type T 
Csharp :: c# double to string with dot 
Csharp :: how to remove all buttons on a form C# 
Csharp :: c# list subfolders 
Csharp :: how to add a queue unity 
Csharp :: unity get all children 
Csharp :: string reverse c# 
Csharp :: string isnullorempty vs isnullorwhitespace 
Csharp :: replace index in string c# 
Csharp :: C# get md5 of file 
Csharp :: get folder path winforms 
Csharp :: .net get system environment variable 
Csharp :: unity vs unreal for beginners 
Csharp :: asp.net core get root url in view 
Csharp :: swap two numbers c# 
Csharp :: c# contains() 
Csharp :: unity button press 
Csharp :: array sort c# 
Csharp :: joins List of strings 
Csharp :: c# execute shell command 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =