My program uses a class called Time2
. I have the reference added to TimeTest
but I keep getting the error, 'Time2' is a 'namespace' but is used like a 'type'
.
Could someone please tell me what this error is and how to fix it?
namespace TimeTest { class TimeTest { static void Main(string[] args) { Time2 t1 = new Time2(); } } }
I suspect you've got the same problem at least twice.
Here:
namespace TimeTest { class TimeTest { }
... you're declaring a type with the same name as the namespace it's in. Don't do that.
Now you apparently have the same problem with Time2
. I suspect if you add:
using Time2;
to your list of using
directives, your code will compile. But please, please, please fix the bigger problem: the problematic choice of names. (Follow the link above to find out more details of why it's a bad idea.)
(Additionally, unless you're really interested in writing time-based types, I'd advise you not to do so... and I say that as someone who does do exactly that. Use the built-in capabilities, or a third party library such as, um, mine. Working with dates and times correctly is surprisingly hairy. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With