文字列のセットを含むクラスを定義しようとしましたか(ゲッターとセッターを使用)?このようなものを試してください
class Data
{
public string Year{get;set;}
public string Month{get;set;}
public string WeatherReport1{get;set;}
public string WeatherReport2{get;set;}
public string WeatherReport3{get;set;}
public string WeatherReport4{get;set;}
public string WeatherReport5{get;set;}
}
このクラスのオブジェクトを使用してください。 Year、Month、WeatherReport1、...の値を設定します。このクラスの型の配列にクラスのオブジェクトを追加します。このように少し
class Data
{
public string Year { get; set; }
public string Month { get; set; }
public string WeatherReport1 { get; set; }
public string WeatherReport2 { get; set; }
public string WeatherReport3 { get; set; }
public string WeatherReport4 { get; set; }
public string WeatherReport5 { get; set; }
}
class Program
{
static void Main(string[] args)
{
Data objdata;
Data[] array = new Data[5];
for (int i = 0; i < array.Length; i++)
{
objdata = new Data();
objdata.Year = "Year";
objdata.Month = "Month";
objdata.WeatherReport1 = "report1";
objdata.WeatherReport2 = "report2";
objdata.WeatherReport3 = "report3";
objdata.WeatherReport4 = "report4";
objdata.WeatherReport5 = "report5";
array[i] = objdata;
}
for(int i=0;i<array.Length;i++)
{
Console.WriteLine(array[i].Year+" "+array[i].Month+" "+array[i].WeatherReport1+" "+array[i].WeatherReport2+" "+array[i].WeatherReport3+" "+array[i].WeatherReport4+" "+array[i].WeatherReport5);
}
Console.Read();
}
私はそれが役に立ちそうです。私にお知らせください。私はStackOverflowの新人です。私は新しいものを学ぼうとしています:)
マージソートの実行方法を尋ねていますか? – Pemdas
あなたはクラスを作る必要があるように見えます。その後、入力データをクラス内のさまざまなプロパティに解析します。データ全体がクラスのリストコレクションになります。 – jdweng
あなたが記述した並べ替えの順序は、*プレゼンテーションレイヤ*の問題です。最初に入力を解析するときに解決したいとは限りません。 –