1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
public enum CodeType {
Bla, // ["a", 5]
Bli, // ["b", 4]
Blo // ["c", 2]
}
public class CodeDecrypt
internal static string GetValue(string input, char key, int length)
{
return input.Substring(input.IndexOf(key), length);
}
public static List<Dictionary<CodeType , string>> Decrypt(string input)
{
Dictionary<BarCodeType, string> values = new Dictionary<BarCodeType, string>();
if (input.Contains("a"))
{
values.Add(CodeType.Bla, GetValue(input, 'a', 5));
}
if (input.Contains("b"))
{
values.Add(CodeType.Bli, GetValue(input, 'b', 4));
}
if (input.Contains("c"))
{
values.Add(CodeType.Blo, GetValue(input, 'c', 2));
}
return values;
}
static void Main()
{
Decrypt("aABCDEbFGHIcJK");
}
} |
Partager