好吧,我想将整个“TRY”写入以下 Get Set 方法
try
{
string PUBLICKEY = "";
switch (Path.GetFileName(file).Substring(0, 2))
{
case "00":
PUBLICKEY = "453453453453";
break;
case "01":
PUBLICKEY = "3453453453453";
break;
case "02":
PUBLICKEY = "4434534563453";
break;
case "03":
PUBLICKEY = "453453453453453";
break;
case "04":
PUBLICKEY = "453453453453453";
break;
case "06":
PUBLICKEY = "345345345345345";
break;
case "09":
PUBLICKEY = "3456456456466";
break;
case "11":
PUBLICKEY = "4564564564";
break;
case "13":
PUBLICKEY = "456456456546564";
break;
case "15":
PUBLICKEY = "464565464565456464456";
break;
case "17":
PUBLICKEY = "456465564564546";
break;
case "19":
PUBLICKEY = "213134378";
break;
case "20":
PUBLICKEY = "456546456546564";
break;
case "21":
PUBLICKEY = "786786786876";
break;
case "26":
PUBLICKEY = "456456456456";
break;
case "28":
PUBLICKEY = "456786786786";
break;
case "34":
PUBLICKEY = "456546456";
break;
case "35":
PUBLICKEY = "456546456546";
break;
case "36":
PUBLICKEY = "456456464565465";
break;
case "37":
PUBLICKEY = "45655466456";
break;
default:
PUBLICKEY = "456456456456546"; //ZECHL
break;
}
(真正的公钥已被删除)
public class PublicKeys : List<PublicKey>
{
}
public class PublicKey
{
public string CC { get; set; }
public string publicKey { get; set; }
}
我只是一片空白,我无法再思考了......
我试过这样的事情:
public class PublicKeys : List<PublicKey>
{
public PublicKeys()
{
publicKeys();
}
private void publicKeys()
{
this.Add(new PublicKey("00", "456456"));
this.Add(new PublicKey("01", "456456456"));
this.Add(new PublicKey("02", "45654645"));
this.Add(new PublicKey("03", "45645645646"));
this.Add(new PublicKey("04", "456456546456"));
this.Add(new PublicKey("06", "456456546456"));
this.Add(new PublicKey("09", "456456456456"));
this.Add(new PublicKey("11", "6456546456456"));
this.Add(new PublicKey("13", "456456456456"));
this.Add(new PublicKey("15", "45654645645"));
this.Add(new PublicKey("17", "456456546456564"));
this.Add(new PublicKey("19", "45645645645646565"));
this.Add(new PublicKey("20", "456456456546456"));
this.Add(new PublicKey("21", "4564565456645"));
this.Add(new PublicKey("26", "456465564456"));
this.Add(new PublicKey("28", "456456546456"));
this.Add(new PublicKey("34", "465456546654"));
this.Add(new PublicKey("35", "456456456456564"));
this.Add(new PublicKey("36", "45654456456465"));
this.Add(new PublicKey("37", "456456456456456"));
//PUBLICKEY = "4566554656654456564564456564"; //ZECHL
}
public string GetKey(string cc)
{
return getKey(cc);
}
private string getKey(string cc)
{
string key = "";
this.ForEach(pk =>
{
if (pk.CC == cc)
{
key = pk.publicKey;
}
}
);
return key;
}
}
public class PublicKey
{
public string CC { get; set; }
public string publicKey { get; set; }
public PublicKey()
{
}
public PublicKey(string cc, string publicKey)
{
this.CC = cc;
this.publicKey = publicKey;
}
}
任何建议将不胜感激..
TIA