我的int selectID没有显示任何东西。
这是我的代码:
int chooseID = int.Parse(e.CommandArgument.ToString());
System.Diagnostics.Debug.WriteLine("e.CommandArgument.ToString()", e.CommandArgument.ToString());
System.Diagnostics.Debug.WriteLine("chooseID", chooseID);
这是输出:
4: e.CommandArgument.ToString()
chooseID
您的意图不是使用Debug.WriteLine
。您正在使用WriteLine(string, object[])
过载,但目的是第一个参数是格式字符串,其中包含占位符,然后用其余的参数代替。
所以您想要类似的东西:
Debug.WriteLine("e.CommandArgument: {0}", e.CommandArgument);
Debug.WriteLine("chooseID: {0}", chooseID);
,或者您可以使用字符串插值:
Debug.WriteLine($"e.CommandArgument: {e.CommandArgument}");
Debug.WriteLine($"chooseID: {chooseID}");