解析数据然后附加标题

时间:2015-06-23 11:37:35

标签: c#

在我的班级中,我将数据划分为19个不同的字符串,然后我尝试添加显示在解析数据前面底部的标题。

我得到了溢出 - 我做错了什么?

public class Call
{
    public Call(string ParsedData)
    {
        ParseData(ParsedData);
    }


    private void ParseData(string ParsedData)
    {
       string[] stringSeparators = new string[] { "," };
       string[] items = ParsedData.Split(stringSeparators, StringSplitOptions.None);

       try
       {
           using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\Public\TestFolder\Writetext1.txt", true))
           {

               List<Call> CallList = new List<Call>();
               foreach (string s in items)
               {
                   Console.WriteLine(s);

                   Call c = new Call(s);
                   CallList.Add(c);

                   file.WriteLine(c);
               }
           }
       }

       catch (Exception e)
       {
           Console.WriteLine("{0} Exception caught.", e);
       }

       CallID = items[0];
       Num2 = items[1];
       UTCStart = items[2];
       CallLengthSeconds = items[3];
       FromPort = items[4];
       FromDescription = items[5];
       FromCIDName = items[6];
       FromCIDNumber = items[7];
       ToPort = items[8];
       ToDescription = items[9];
       ToCIDName = items[10];
       ToCIDNumber = items[11];
       Num14 = items[12];
       Digits = items[13];
       TC = items[14];
       Num17 = items[15];
       FromDNISName = items[16];
       FromDNISNumber = items[17];
       CallConnected = items[18];
       //etc
   }
   public string CallID { get; set; }
   public string Num2 { get; set; }
   public string UTCStart { get; set; }
   public string CallLengthSeconds { get; set; }
   public string FromPort { get; set; }
   public string FromDescription { get; set; }
   public string FromCIDName { get; set; }
   public string FromCIDNumber { get; set; }
   public string ToPort { get; set; }
   public string ToDescription { get; set; }
   public string ToCIDName { get; set; }
   public string ToCIDNumber { get; set; }
   public string Num14 { get; set; }
   public string Digits { get; set; }
   public string TC { get; set; }
   public string Num17 { get; set; }
   public string FromDNISName { get; set; }
   public string FromDNISNumber { get; set; }
   public string CallConnected { get; set; }
}

1 个答案:

答案 0 :(得分:1)

此:

Call c = new Call(s);

呼叫

public Call(string ParsedData)
{
    ParseData(ParsedData);
}

调用

private void ParseData(string ParsedData)

您可以在其中找到:

Call c = new Call(s);

请参阅...?