如何读取值并将其放入数组C# [英] how can read values and put them in Array C#
本文介绍了如何读取值并将其放入数组C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我今天开始dicoverig C#...您知道有些困难
I start dicoverig C# today ... as you know there is some difuculties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] arr = new int[3];
int i;
for (i=0; i < 3; i++)
{
arr[i] = Console.Read();
}
for (int k = 0; k < 3; k++)
{
Console.Write(arr[k]);
}
Console.ReadKey();
}
}
}
此代码不适用于我当我编译它时...使我一次投入价值然后他打印其他值!任何有帮助的人
this code didn't work with me when i compiled it ...it make me put value for one time then he print other values ! any one here to help
推荐答案
尝试一下
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int[] arr = new int[3];
int i;
for (i = 0; i < 3; i++)
{
arr[i] = Convert.ToInt32(Console.ReadLine());
}
for (int k = 0; k < 3; k++)
{
Console.WriteLine(arr[k]);
}
Console.ReadKey();
}
}
}
再见.
这篇关于如何读取值并将其放入数组C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文