我正在做这个分割数据的项目。我在下面显示了我的代码,然后附加了输出。我在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(键,值格式)中。
***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);
我对此进行了硬编码。请提供想法/代码来集中精力。