【发布时间】:2012-07-04 06:58:16
【问题描述】:
public List<int> GetListIntKey(int keys)
{
int j;
List<int> t;
t = new List<int>();
int i;
for (i = 0; ; i++)
{
j = GetKey((keys + i).ToString());
if (j == null)
{
break;
}
else
{
t.Add(j);
}
}
if (t.Count == 0)
return null;
else
return t;
}
问题就出来了:
j = GetKey((keys + i).ToString());
我收到错误说:
无法将类型'string'隐式转换为'int'
现在GetKey 函数是字符串类型:
public string GetKey(string key)
{
}
我该怎么办?
【问题讨论】:
-
This question询问关于将int转换为字符串,但您已经弄清楚了,错误消息是关于将字符串转换为int。
-
请编辑您的问题并更正其标题。问题是关于字符串到 int 的转换,而不是 int 到字符串。
-
我喜欢大多数正确答案被否决的方式。
-
这是一个几乎重复的问题,有很多正确答案(还有很多反对票,然后是反对票)。这个问题肯定无法为 SO 添加价值,应该像@hvd 建议的那样关闭。
标签: c#