问题是,我想要将方法定义为类似于tryparse
private bool TryParse(字符串值,输出bool等)
{
试试
{
int.Parse(value);
}
catch(例外)
{
throw;
}
我尝试了什么:
私人bool TryParse(字符串值,out bool等)
{
试试
{
int.Parse(value);
etc = true;
返回true;
}
catch(例外)
{etc = false;
return = false;
throw;
}
Question is that want me to define method as tryparse like that
private bool TryParse(string value,out bool etc)
{
try
{
int.Parse(value);
}
catch (Exception)
{
throw;
}
What I have tried:
private bool TryParse(string value,out bool etc)
{
try
{
int.Parse(value);
etc = true;
return true;
}
catch (Exception)
{etc = false;
return = false;
throw;
}
这篇关于使用trycatchthrow定义类似tryparse的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!