111,120
社区成员
发帖
与我相关
我的任务
分享
能详细点吗[/quote]
拆开就容易理解了。
string filePath = @"d:\Test.txt";
string[] lines = File.ReadAllLines(filePath,Encoding.Default);
IEnumerable<int> results = lines.Select(p=>int.Parse(p.Trim()));
int[] arr = results.ToArray();
int y=50;
int x=0;
if (y < 100)
{
x = arr[0];
}
else if (y >= 100 && y < 200)
{
x = arr[2];
}
Console.WriteLine("{0}\n", x);double[] arr = System.IO.File.ReadAllLines(@"e:/Test.txt", System.Text.Encoding.Default).Select(p => double.Parse(p.Trim())).ToArray();
能详细点吗
int[] arr = System.IO.File.ReadAllLines(@"e:/Test.txt", System.Text.Encoding.Default).Select(p=>int.Parse(p.Trim())).ToArray();
//譬如第三行的数字:arr[2];
满意就结贴
string[] lines = File.ReadAllLines("your path");//如果判断范围少的话,也可以循环一行行读取
int y;
string x;
if (y < 100)
{
x = lines[0];
}
else if (y >= 100 && y < 200)
{
x = lines[2];
}
//感觉你这个比喻不就是整除100嘛……