我有应该输出fee_paid_int
为'20'
和total_student_int
为'30'
怎么过我收到以下错误下面的C#代码时,我调试的代码int fee_paid_int = Convert.ToInt32(fee_paid_string.Trim());
无法将字符串转换为int。错误信息:输入字符串的不正确的格式
System.FormatException: Input string was not in a correct format.
C#
//Total Student's - Not counting Graduated, Withdrawn or Temporarily Withdrawn
DataView t_stu = (DataView)total_students_count.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView t_stu_sql in t_stu)
{
total_students_count_label.Text = "Total Current Students: <b>" + t_stu_sql["total_students"].ToString() + "</b><p></p>";
}
// Total Fee's Paid to Date
DataView f_paid = (DataView)fees_paid_count.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView fee_paid_sql in f_paid)
{
fees_paid_count_label.Text = "Total Fee's Paid to date: <b>" + fee_paid_sql["fee_paid"].ToString() + "</b><p></p>";
}
int fee_paid_int = Convert.ToInt32(total_students_count_label.Text.Trim());
int total_student_int = Convert.ToInt32(fees_paid_count_label.Text.Trim());
int fee_paid_percent = (int)Math.Round((double)(100 * fee_paid_int)/total_student_int);
fee_paid_percent_label.Text = "Total Percent of Student's who have fully paid their Tution Fee to date " + fee_paid_percent + "%";
int fee_paid_percent
应该等于66.66
,任何帮助,将不胜感激。
啊,当然,这是一个非常愚蠢的错误。感谢您解决这个问题。 – mcclosa