首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

定义一个抛出错误的类,有语法异常

2012-06-05 
定义一个抛出异常的类,有语法错误using Systemusing System.Collections.Genericusing System.Linqusin

定义一个抛出异常的类,有语法错误
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication21
{
  class MyException throws IndexOutOfRangeException
  {
  public int[] myArray=new int[4]{1,2,3,4};
  }
  class TestException
  {
  static void Main()
  {
  MyException me=new MyException();
  try
  {
  me.myArray[5]=5;
  }
  catch(IndexOutOfRangeException ex)
  {
  Console.WriteLine("出现错误了!");
  Console.WriteLine(ex.Data.ToString());
  }
  Console.WriteLine();
  }
  }
}
书上的代码,红色的字给出了红色的波浪线,哪里出问题了?

[解决办法]
throws IndexOutOfRangeException ,C# 没有这语法吧,去掉就行了
[解决办法]
throws ==>:
[解决办法]
throws 这貌似是java语法……
[解决办法]
看错了,throws 换成 :(冒号)
[解决办法]
1.throws IndexOutOfRangeException删掉
2.IndexOutOfRangeException不能继承,楼上都在卖萌吗
[解决办法]

探讨

1.throws IndexOutOfRangeException删掉
2.IndexOutOfRangeException不能继承,楼上都在卖萌吗

[解决办法]
探讨

引用:

1.throws IndexOutOfRangeException删掉
2.IndexOutOfRangeException不能继承,楼上都在卖萌吗

对的,是不能继承IndexOutOfRangeException类的

[解决办法]
探讨
1.throws IndexOutOfRangeException删掉
2.IndexOutOfRangeException不能继承,楼上都在卖萌吗

热点排行