Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Specialized;
using System.Threading;
using System.Reflection;
using System.Data;
namespace TestArray
{
class Program
{
//測試順序儲存類
static void Main(string[] args)
{
string s1 = "red";
string s2 = "blue";
string s3 = "yellow";
SeqStructure<string> s = new SeqStructure<string>(3);
s.AddData(s1);
s.AddData(s2);
s.AddData(s3);
s.DisplayData();
Console.ReadLine();
}
}
/// <summary>
/// 資料元素,關係的儲存表示及演算法實現
/// </summary>
/// <typeparam name="T"></typeparam>
class SeqStructure<T>
{
T[] data; //T代表資料元素的儲存表示,數組代表資料元素順序存放
int i;
public SeqStructure(int size)
{
data = new T[size];
}
public void AddData(T var)
{
data[i++] = var;
}
public void DisplayData()
{
for (int j = 0; j < data.Length; j++)
{
Console.Write(data[j] + "");
}
}
}
}