C# 如何检查文本框int值是否大于datagridview CurrentRow int值

C# 如何检查文本框int值是否大于datagridview CurrentRow int值,c#,C#,如何检查文本框int值是否大于datagridview CurrentRow int值 What I have if (int.Parse(txtAddQty.Text) >= dtgList.CurrentRow.Cells[5].Value) { // Here what I want to do } 但以错误结束运算符“>=”不能应用于“in

如何检查文本框int值是否大于datagridview CurrentRow int值

What I have 

            if (int.Parse(txtAddQty.Text) >= dtgList.CurrentRow.Cells[5].Value)
            {
                // Here what I want to do
                
            }
但以错误结束运算符“>=”不能应用于“int”和“object”类型的操作数


任何人都有解决方案。如果您确定单元格的值类型,谢谢

if (int.Parse(txtAddQty.Text) >= (int)dtgList.CurrentRow.Cells[5].Value)
{
     // Here what I want to do
                
}
否则,您将更安全:

string cellValue = dtgList.CurrentRow.Cells[5].Value.ToString();
int intValue;
bool isInt = int.TryParse(cellValue, out intValue);
if (int.Parse(txtAddQty.Text) >= intValue && isInt)
{
     // Here what I want to do
                
}