我的手机有像这样的数据 “标题=幸福,ISBN = 123,作者=约翰;名称=奇迹,ISBN = 456,作者=劳拉”
即。同一单元格中有两条记录。 是否可以像下面这样阅读?
Book[0].title = "Happiness"
Book[1].title = "Miracle"
Book[0].ISBN = "123"
Book[1].ISBN = "456"
记录数=“;”的数量+ 1
由于
答案 0 :(得分:0)
这就是我最终要做的事情。
public class ParsedInfo
{
public string one { get; set; }
public string two { get; set; }
public string three { get; set; }
}
public List<ParsedInfo> GiveParsedInfo(string RawData)
{
string temp;
List<ParsedInfo> list = new List<ParsedInfo>();
temp = Data.ToString();
if (temp.Contains(","))
{
// first break it into multiple records for temp
String[] Multiple = temp.Split(Convert.ToChar(";"));
try
{
for (int j = 0; j < Multiple.Length; j++)
{
string rowdata = Multiple[j];
String[] strCols = rowdata.Split(Convert.ToChar(","));
list.Add(new ParsedInfo()
{
one = strCols[0].Substring(3),
two = strCols[1].Substring(3),
three = strCols[2].Substring(3),
});
}
}
catch (Exception e)
{
Console.WriteLine(Name, e.Message.ToString());
}
}
return list;
}