C#中是否有一个throws关键字,就像Java一样? [英] Is there a throws keyword in C# like in Java?

查看:261
本文介绍了C#中是否有一个throws关键字,就像Java一样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何在C#中使用Java风格的throws关键字

我有一个发生异常的函数
例如说

i have a function where an exception occurs say for example

private void functionName() throws Exception
{
   // some code that might throw an exception
}

谢谢!

推荐答案

不,因为C#中没有检查异常

No, because there are no checked exceptions in C#

如果您尝试记录抛出的异常,请使用标准的xml文档

If you are trying to document exceptions that are thrown, use the standard xml documentation

/// <exception cref="InvalidOperationException">Why it's thrown.</exception>

这篇关于C#中是否有一个throws关键字,就像Java一样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆