我有这两个相当大的数组,一个带有指针,另一个带有字符串来识别它们,所以我可以使用int z作为索引来访问它们。我偶尔会回来给他们做点什么。
//LUTs(names start, names end, descriptions strart, descriptions end)
UInt32[,] multiPointer = {{0x81656650, 0x816571F8, 0x816571FC, 0x81657DA4},//item
{0x81671DE0, 0x81671FE8, 0x81672820, 0x81672A28},//chest
{0x81671FEC, 0x816721DC, 0x81672A2C, 0x81672C1C},//arm
{0x816721E0, 0x816723D4, 0x81672C20, 0x81672E14},//waist
{0x816723D8, 0x816725C8, 0x81672E18, 0x81673008},//legging
{0x816725CC, 0x816727FC, 0x8167300C, 0x8167323C},//headgear
{0x81672800, 0x8167281C, 0x81673240, 0x8167325C},//talisman
{0x81666B20, 0x81666C94, 0x81667290, 0x81667404},//GS
{0x81666C98, 0x81666E04, 0x81667408, 0x81667574},//SnS
{0x81666E08, 0x81666F5C, 0x81667578, 0x816676CC},//hammer
{0x81667108, 0x8166728C, 0x81667878, 0x816679FC},//lance
{0x81670600, 0x8167064C, 0x816706F4, 0x81670740},//bg frame
{0x816705B0, 0x816705FC, 0x816706A4, 0x816706F0},//bg barrel
{0x81670650, 0x816706A0, 0x81670744, 0x81670794},//bg stock
{0x81666F60, 0x8166700C, 0x816676D0, 0x8166777C},//LS
{0x81667010, 0x81667104, 0x81667780, 0x81667874},//SwA
{0x8168423C, 0x816842DC, 0x0,0x0},//monster
{0x816856F8, 0x816858CC, 0x816858D0, 0x81685AA4},//title
{0x81656FEC, 0x816571F8, 0x0, 0x0}//decorations
};
string[] stuff = { "Item",
"Chest",
"Arm",
"Waist",
"Legging",
"Headgear",
"Talisman",
"Great Sword",
"Sword and Shield",
"Hammer", "Lance",
"Bowgun Frame",
"Bowgun Barrel",
"Bowgun Stock",
"Longsword",
"Switch Axe",
"Monster",
"Title",
"Decorations"
};
抱歉这些可怕的名字。之前他们是5个不同的数组,直到我了解了多维数组。但后来我无法将字符串与十六进制组合。有没有办法组合这两个数组,使它看起来更整洁?
答案 0 :(得分:0)
创建一个包含string
和4 UInt32
public class Item {
public UInt32 Value1 { get; private set; }
public UInt32 Value2 { get; private set; }
public UInt32 Value3 { get; private set; }
public UInt32 Value4 { get; private set; }
public string Stuff { get; private set; }
}
现在您可以创建一个Item
:
public Item[] items = {
{ 0x81656650, 0x816571F8, 0x816571FC, 0x81657DA4, "Item" },
}
等等......
答案 1 :(得分:0)
为什么不创建一个类来保存信息?它比几个数组有更多的意义:
class Thing
{
public string ThingType { get;set; }
public UInt32 NameStart { get; set; }
public UInt32 NameEnd { get; set; }
public UInt32 DescriptionStart { get; set; }
public UInt32 DescriptionEnd { get; set; }
}
然后您可以保留Things
答案 2 :(得分:0)
也许你也可以使用linq查询作为你的结构
var r1 = Enumerable.Range(0, multiPointer.GetLength(0))
.Select(i => new
{
Index = i,
Col1 = multiPointer[i, 0],
Col2 = multiPointer[i, 1],
Col3 = multiPointer[i, 2],
Col4 = multiPointer[i, 3]
});
var r2 = stuff.Select((v, i) => new { Index = i, Value = v });
var result = from p in r1
from q in r2
where p.Index == q.Index
select new
{
Stuff = q.Value,
Col1 = p.Col1,
Col2 = p.Col2,
Col3 = p.Col3,
Col4 = p.Col4,
};
foreach (var r in result)
{
Console.WriteLine(string.Format("{0} : {1} , {2} , {3} , {4}", r.Stuff, r.Col1, r.Col2, r.Col3, r.Col4));
}
Console.Read();