c#foreach循环_C#| 使用foreach循环打印整数数组
生活随笔
收集整理的這篇文章主要介紹了
c#foreach循环_C#| 使用foreach循环打印整数数组
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
c#foreach循環
Given an integer array and we have to print its elements using "foreach loop" in C#.
給定一個整數數組,我們必須在C#中使用“ foreach循環”打印其元素 。
Syntax for foreach loop:
foreach循環的語法:
foreach (element in iterable-item){// body of foreach loop}Program:
程序:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace ConsoleApp1 {class Program{static void Main(string[] args){int[] data = { 12, 45, 67, 879, 89 };foreach(int item in data){Console.WriteLine(item);}Console.ReadKey();}} }Output
輸出量
12 45 67 879 89翻譯自: https://www.includehelp.com/dot-net/printing-an-integer-array-using-foreach-loop.aspx
c#foreach循環
總結
以上是生活随笔為你收集整理的c#foreach循环_C#| 使用foreach循环打印整数数组的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java类class isAssigna
- 下一篇: c# char unsigned_dll