aspxページにテキストボックスがあります
<asp:TextBox ID="txtrandom" runat="server"></asp:TextBox>
.csページでは、そのテキストボックスから値を取得し、ループint
で使用できるように変換しています。for
.cs ページ内
int random;
random = Convert.ToInt16(txtrandom.Text);
for (int i = 0; i < random; i++)
{
//other code
}
しかし、私が実行していると、エラーが発生しますInput string was not in correct format
.How to convert it int
?