【发布时间】:2012-02-14 09:21:39
【问题描述】:
我目前距离工作程序只有 2 个错误。我将发布包含错误的行及其变量的定义,最后是错误。请告诉我哪里错了。谢谢。
private Dictionary<string, bool[]> letterData = new Dictionary<string, bool[]>();
public char[] mapNeurons()
{
char[] map = new char[this.letters.Items.Count];
for (int i = 0; i < map.Length; i++)
{
map[i] = '?';
}
for (int i = 0; i < this.letters.Items.Count; i++)
{
double[] input = new double[Form1.DOWNSAMPLE_HEIGHT * Form1.DOWNSAMPLE_WIDTH];
char ch = ((string)(this.letters.Items[i]))[0];
bool[] data = this.letterData[ch]; //line contains errors
for (int j = 0; j < input.Length; j++)
{
input[j] = data[j] ? 0.5 : -0.5;
}
int best = this.network.Winner(input);
map[best] = ch;
}
return map;
}
这是错误
错误 1 'System.Collections.Generic.Dictionary.this[string]' 的最佳重载方法匹配有一些无效参数
错误 2 参数 '1':无法从 'char' 转换为 'string'
我使用 Char 而不是 String 因为如果使用 String 它将返回加载的字符串的整行,我只想返回字符串的第一个字母
例如:数据 = A1:000001100000000110000000111000000011100000001
如果使用字符串,它将返回整行,我只希望它返回'A'
新发现的问题: 当我输入数据时,我将数据放入'A1'键中,这解释了为什么我使用字符串,所以当它因为它是字符而没有找到'A1'时,它只是找到'A'这就是它返回'?'的原因,如果我使用字符串 n 是否可以只读取字符串行中的第一个字符“A”?
【问题讨论】:
-
它就在错误中:您无法将字符转换为字符串。也许你需要一个 Dictionary
? -
我需要字典是其他函数的字符串,只有这个我需要返回字符而不是字符串