Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Inheritance Custom Exceptions

Jonathan Toomey
Jonathan Toomey
1,330 Points

Why is OutOfBoundsException not found within namespace even when I put the exception classes in the same file? Using VS

Hello, I've tried this course twice and both times I get to this video and I have an error saying that OutOfBoundsException is not recognized in the namespace. I've tried moving the class declarations into the same file but it still doesn't work.

I'm using Visual Studio for this as its what I use at work. The VS solution is to create a class for OutOfBoundsException but it obviously already exists

1 Answer

William Ruiz
William Ruiz
10,027 Points

Have you included

using System;

to the top of your Exceptions.cs file? When you right-click to "Add > Class" to create the Exceptions.cs is it auto-filling some other namespace, than that of your expected project's name?