예제 #1
0
    public void ReadTable(byte[] bytes, ref GameTable tab)
    {
        if (tab == null)
        {
            return;
        }
        string strAll = Encoding.UTF8.GetString(bytes);

        string[] lines = strAll.Split('\n');

        int row = 0;

        for (int index = 0; index < lines.Length; index++)
        {
            //第一行为表头
            if (index == 0)
            {
                continue;
            }
            string str = lines[index];
            //空行或者注释行
            if (str.Length < 1 || str[0] == '#')
            {
                continue;
            }

            string[] array = str.Split('\t');

            if (array.Length == 0)
            {
                continue;
            }

            for (int ndx = 0; ndx < array.Length; ndx++)
            {
                string strField = array[ndx];
                tab.AddValue(row, ndx, strField.Trim());
            }
            row++;
        }
        tab.row = row;
    }