using ShootCore.Core;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
public class MyTable
{
public static MyTable[] Array = null;
public bool BoolValue;
public int IntValue{ get; private set; }
public float[] FloatArray;
public String[] StringArray{ get; private set; }
/*public MyTable(Random random,string content)
{
BoolValue = random.Next(0,2) == 0 ? false : true;
IntValue = random.Next(0,10000);
FloatArray = new float[random.Next(1,10)];
for (int i = 0; i < FloatArray.Length; ++i)
{
FloatArray[i] = random.Next(1,566) / 1000f;
}
StringArray = new string[random.Next(1,5)];
for (int i = 0; i < StringArray.Length; ++i)
{
StringArray[i] = content + i.ToString();
}
}*/
public void OutPut()
{
Console.Write("{0}\t{1}\t",BoolValue,IntValue);
Console.Write("{");
foreach (var val in FloatArray)
{
Console.Write("{0},",val);
}
Console.Write("}\t");
if (StringArray != null)
{
Console.Write("{");
foreach (var val2 in StringArray)
{
Console.Write("{0};;;", val2);
}
Console.Write("}\n");
}
else Console.Write("NULL\n");
}
}
namespace ShootCore
{
class Global
{
static void Main(string[] args)
{
/*Random random = new Random();
List<Object> table = new List<Object>();
table.Add(new MyTable(random, "制表"));
table.Add(new MyTable(random, "单位"));
table.Add(new MyTable(random, "妹子"));
table.Add(new MyTable(random, "优格"));
TitanTabTools.SaveTabToPath(".", table); */
Console.WriteLine("开始读数据!");
if( TitanTabTools.CreateTabFromPach("./MyTable.txt") )
{
if (MyTable.Array != null && MyTable.Array.Length > 0)
{
Console.WriteLine(MyTable.Array.Length);
foreach (var val in MyTable.Array)
{
val.OutPut();
}
}
}
}
}
}
上图是测试的结果,控制台的前半段是从本地文件读取的内容,内容尾部故意添加了很多无效的空格和制表符,控制台中输出行‘4’向下是已经填充到目标对象身上的有效数据。