無法確定陣列長度,要動態存取Grid陣列時:
List<Grid> dynamicGrid = new List<Grid>();
加入物件:
Grid myGrid = new Grid();
dynamicGrid.Add(myGrid)
取得物件,假設想要取得第一萬兩千三百四十五個Grid:
Grid tmpGrid = dynamicGrid[12345];
參考頁:http://forums.asp.net/p/1188478/2036031.aspx#2036031
創造沒有規則
List<Grid> dynamicGrid = new List<Grid>();
Grid myGrid = new Grid();
dynamicGrid.Add(myGrid)
Grid tmpGrid = dynamicGrid[12345];
using System.Text;
private string StringToUnicode(string srcText)
{
string dst = "";
char[] src = srcText.ToCharArray();
for (int i = 0; i < src.Length; i++)
{
byte[] bytes = Encoding.Unicode.GetBytes(src[i].ToString());
string str = @"\u" + bytes[1].ToString("X2") + bytes[0].ToString("X2");
dst += str;
}
return dst;
}
using System.Globalization;
private string UnicodeToString(string srcText)
{
string dst = "";
string src = srcText;
int len = srcText.Length / 6;
for (int i = 0; i <= len - 1; i++)
{
string str = "";
str = src.Substring(0, 6).Substring(2);
src = src.Substring(6);
byte[] bytes = new byte[2];
bytes[1] =
byte.Parse(int.Parse
(str.Substring(0,2),NumberStyles.HexNumber).ToString());
bytes[0] = byte.Parse(int.Parse
(str.Substring(2, 2),NumberStyles.HexNumber).ToString());
dst += Encoding.Unicode.GetString(bytes);
}
return dst;
}
string UnicodeToString(string srcText)
{
string dst = "";
string src = srcText;
int len = srcText.Length / 6;
for (int i = 0; i <= len - 1; i++)
{
string str = "";
str = src.Substring(0, 6).Substring(2);
src = src.Substring(6);
byte[] bytes = new byte[2];
bytes[1] = byte.Parse(int.Parse(str.Substring(0, 2),
NumberStyles.HexNumber).ToString());
bytes[0] = byte.Parse(int.Parse(str.Substring(2, 2),
NumberStyles.HexNumber).ToString());
Encoding enc = Encoding.GetEncoding("utf-16") ;
dst += enc.GetString(bytes, 0, bytes.Length);
}
return dst;
}