在C#中丢失关键字 [英] throws keyword missing in C#

查看:92
本文介绍了在C#中丢失关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在C#中没有''抛出''关键字如java -


i想要声明一个函数并说 -


public int addup(int a,int b)抛出ArithmeticExceptio,

DivideByZeroException

{

...

...

}


就像java一样,因此addup函数只抛出这两种类型的

异常


有替代编码吗?如果它没有被包括在内,为什么?


我是c的新手#


你的观点是热切期待的
< br $>
谢谢


Vijay

Why isn''t there a ''throws'' keyword in C# like java -

i would like to declare a function and say -

public int addup(int a, int b) throws ArithmeticExceptio,
DivideByZeroException
{
...
...
}

just like java so that addup function only throws these two types of
exceptions

is there any alternate coding? and if its not been included then why?

i''m new to c#

Your views are eagerly awaited

Thanks

Vijay

推荐答案

有一个投掷keywrod,在线查看msdn
http://msdn.microsoft.com/library/en...owStatement.as

p


希望这有助于


Publicjoe


C#教程 http://www.publicjoe.f9.co.uk/csharp/tut.html

C#Ebook at a a rel = nofollowhref =http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html\"target =_ blank> http://www.publicjoe.f9.co.uk/csharp/ samples / ebook.html

VB教程 http://www.publicjoe.f9.co.uk/vbnet/vbnet.html

VB电子书 http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html

镜像在 http://www.dowhileloop。 com / publicjoe /
http://www.publicjoe。 justbe.com/


有用的文章 http://www.madsally.co.uk


< vi ******* @ yahoo.com>在消息中写道

news:11 ********************** @ o13g2000cwo.googlegr oups.com ...
There is a throw keywrod, check out the msdn online at
http://msdn.microsoft.com/library/en...owStatement.as
p

Hope this helps

Publicjoe

C# Tutorial at http://www.publicjoe.f9.co.uk/csharp/tut.html
C# Ebook at http://www.publicjoe.f9.co.uk/csharp/samples/ebook.html
VB Tutorial at http://www.publicjoe.f9.co.uk/vbnet/vbnet.html
VB Ebook at http://www.publicjoe.f9.co.uk/vbnet/samples/ebook.html
Mirrors at http://www.dowhileloop.com/publicjoe/ and
http://www.publicjoe.justbe.com/

Useful Articles at http://www.madsally.co.uk

<vi*******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
为什么在C#中没有''抛出''关键字,比如java -

我想声明一个函数并说 -

public int addup(int a,int b)抛出ArithmeticExceptio,
DivideByZeroException
{
...
...
}

就像java使addup函数只抛出这两种类型的

是否有任何替代编码?如果它没有被包括在内那么为什么呢?

我是c的新手#

你的意见正热切期待

谢谢

Vijay
Why isn''t there a ''throws'' keyword in C# like java -

i would like to declare a function and say -

public int addup(int a, int b) throws ArithmeticExceptio,
DivideByZeroException
{
...
...
}

just like java so that addup function only throws these two types of
exceptions

is there any alternate coding? and if its not been included then why?

i''m new to c#

Your views are eagerly awaited

Thanks

Vijay



< vi ******* @ yahoo.com>在消息中写道

新闻:11 ********************** @ o13g2000cwo.googlegr oups.com ...
<vi*******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
为什么C#中没有''throws''关键字如java -
Why isn''t there a ''throws'' keyword in C# like java -




查看try ... catch ...最后语法
http://msdn.microsoft.com/library/de...ogether_PG.asp


微软已决定反对添加Throws语法会强制

方法的调用者明确捕获它抛出的异常。


为了清除方法的用户,你可以使用XML

注释并添加异常(s?)元素。但这纯粹是b
文件并且不执行编码。


-

Patrik L?wendahl [C#MVP ]
http://www.lowendahl.net/ || http://www.cshrp.net

请回复到新闻组。

vi*******@yahoo.com 写道:
Microsoft has decided against adding the Throws syntax which would force
the caller of the method to explicitly catch the exceptions it throws.

For clearification to the user of the methods, you could use XML
comments and add the exception(s ?) element. But this is purely
documentual and don''t enforce coding.

--
Patrik L?wendahl [C# MVP]
http://www.lowendahl.net/ || http://www.cshrp.net
Please reply only to the newsgroup.

vi*******@yahoo.com wrote:
为什么在C#中没有''throws''关键字如java -

我想声明一个函数并说 -

public int addup(int a,int b)抛出ArithmeticExceptio,
DivideByZeroException
{
...
...
}
<就像java一样,addup函数只抛出这两种类型的

是否有任何替代编码?如果它没有被包括在内那么为什么呢?

我是c的新手#

你的意见正热切期待

谢谢

Vijay
Why isn''t there a ''throws'' keyword in C# like java -

i would like to declare a function and say -

public int addup(int a, int b) throws ArithmeticExceptio,
DivideByZeroException
{
...
...
}

just like java so that addup function only throws these two types of
exceptions

is there any alternate coding? and if its not been included then why?

i''m new to c#

Your views are eagerly awaited

Thanks

Vijay



这篇关于在C#中丢失关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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