Compiler Error CS1017
Catch clauses cannot follow the general catch clause of a try statement
A catch
block that does not take any parameters must be the last in a series of catch
blocks. For more information on exceptions, see Exceptions and Exception Handling.
The following sample generates CS1017:
// CS1017.cs
using System;
namespace x
{
public class b : Exception
{
}
public class a
{
public static void Main()
{
try
{
}
catch // CS1017, must be last catch
{
}
catch(b)
{
throw;
}
}
}
}
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET feedback
.NET is an open source project. Select a link to provide feedback: