Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?