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();
}
}
}
书上的代码,红色的字给出了红色的波浪线,哪里出问题了?
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();
}
}
}
书上的代码,红色的字给出了红色的波浪线,哪里出问题了?
2.IndexOutOfRangeException不能继承,楼上都在卖萌吗
惭愧,被throws吸引了注意力没注意能不能被继承的问题