【发布时间】:2016-11-14 00:28:36
【问题描述】:
我正在尝试创建一个排序系统,并且我正在尝试将一个相当长的字符串形式的整数列表转换为一个 int 数组,以便更轻松地对数组进行排序。初始字符串数组是通过从文本文件中读取整数列表形成的。
这是代码目前的样子,我目前正在根据年份排序:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace Climate_Sorting_Application
{
public class Program
{
public static string[] monthArray = File.ReadAllLines("Month.txt");
public static string[] yearArrayPre = File.ReadAllLines("Year.txt");
public static string[] afArray = File.ReadAllLines("WS1_AF.txt");
public static string[] rainArray = File.ReadAllLines("WS1_Rain.txt");
public static string[] sunArray = File.ReadAllLines("WS1_Sun.txt");
public static string[] tmaxArray = File.ReadAllLines("WS1_TMax.txt");
public static string[] tminArray = File.ReadAllLines("WS1_TMin.txt");
public static string[] af2Array = File.ReadAllLines("WS2_Rain.txt");
public static string[] rain2Array = File.ReadAllLines("WS2_Rain.txt");
public static string[] sun2Array = File.ReadAllLines("WS2_Sun.txt");
public static string[] tmax2Array = File.ReadAllLines("WS2_TMax.txt");
public static string[] tmin2Array = File.ReadAllLines("WS2_TMin.txt");
public static string arrayToAnalyse;
static void Main(string[] args)
{
Console.WriteLine("Please Specify the Data to be Analysed");
Console.WriteLine("You must specify the Text File name (Do not include .txt");
arrayToAnalyse = Console.ReadLine();
Console.ReadLine();
}
private static void sortProcess()
{
}
}
}
有什么方法可以轻松转换为正确的数据类型?甚至在初始文件读取期间将其转换为 int 值数组的方法?
【问题讨论】: