'namespace' but is used like a 'type'

前端 未结 7 1530
孤独总比滥情好
孤独总比滥情好 2020-11-27 04:35

This is my program the class uses it is called Time2 I have the reference added to TimeTest I keep getting the Error \'Time2\' is a \'namespace\' but is used like a \'type\'

相关标签:
7条回答
  • 2020-11-27 05:40

    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. :)

    0 讨论(0)
提交回复
热议问题