0

私はこのデータの分割に関するプロジェクトを行っています。以下にコードを示し、出力も添付しました。私はAsp.netでやっています。

Receipt No : VH4O-RCTN093246 Receipt Date : 01/01/2015
Fathers Name : sachin tendulkar Mother’s Name : NITHYA
Name of the Student : ARLJN RIKIN RUPAK
Board/Grade/Dvision : ICSE / Grade II / D App/Enr No : VH4O-ENRN04426

上記から、この出力を取得し、それを HashMap(key, Value format) に格納する必要があります。

***Output:***
 Receipt No : VH4O-RCTN093246
 Receipt Date : 01/01/2015
 Receipt No : VH4O-RCTN093246
 Board : ICSE 
 Grade: Grade II 
 Dvision : D 
 App/Enr No : VH4O-ENRN04426

コード:

int length = split_text.Length;

do
{
    string tmp;
    tmp = split_text[i]; // Contain input text

    if (tmp.Contains("Receipt No "))
    {
        string[] words;
        words = tmp.Split(':');

        string[] wor = words[1].Split(' ');
        rep_name1 = wor[1];
    }

    if (tmp.Contains("Name of the Student "))
    {
        string[] words;
        words = tmp.Split(':');

        s_name1 = words[1];
    }
    if (tmp.Contains("Grade"))
    {
        string[] words;
        words = tmp.Split('/');

        string[] wor = words[2].Split(':');

        board = wor[1];
        grade = words[3];
        string[] b = words[5].Split(':');

        enroll_no = b[1];// +read.ReadLine();
    }
    if (tmp.Contains("Fee "))
    {
        string[] words;
        words = tmp.Split(' ');
        fee = words[7];
    }
    length--;
    i++;
}

while (length != 0);

これをハードコードします。これを一般化するためのアイデア/コードを教えてください。

4

0 に答える 0