【发布时间】:2014-06-03 20:57:55
【问题描述】:
使用此代码(sbJava 是一个 StringBuilder):
String androidFindLine = string.Format("Button _{0} = (Button) findViewById(R.id.{0});\"", btnId);
sbJava.Append(androidFindLine);
sbJava.Append(Environment.NewLine);
sbJava.Append(string.Format("_{0}.setOnClickListener(new View.OnClickListener() { ", btnId));
...我明白了,
System.FormatException 未处理 _HResult=-2146233033 _message=输入字符串的格式不正确...
btnId 的值为“btnbutton_up”
有什么问题?
【问题讨论】:
-
btnId的类型是什么 - 绝对是字符串? -
String androidFindLine = string.Format("Button _{0} = (Button) findViewById(R.id.{0});\"", btnId);是否被正确转义?
标签: c# stringbuilder string.format