namespace' but is used like a 'type'
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. :)
Class' is a namespace but is used like a 'type'
BatchResizer
is still a namespace name, though. If it's also the same name as a class, you'll have to be more explicit:
var batchResizer = new Components.BatchResizer();
You could also add a using statement within your namespace:
namespace BatchResizer.ConsoleRunner
{
using Components;
internal class Program
{
private static void Main(string[] args)
{
var batchResizer = new BatchResizer();
}
}
}
If you want to get a bit geeky, then the C# 5.0 spec has this to say:
9.2 Namespace declarations
...The qualified-identifier of a namespace-declaration may be a single identifier or a sequence of identifiers separated by “.” tokens. The latter form permits a program to define a nested namespace without lexically nesting several namespace declarations. For example,
namespace N1.N2
{
class A {}
class B {}
}
is semantically equivalent to
namespace N1
{
namespace N2
{
class A {}
class B {}
}
}
So even if, as you say, no class
is declared in the namespace BatchResizer
, BatchResizer
is declared as a namespace.
xxxxx is a namespace but is used like a Type
Try to use fully qualified name
public ChangeRequestForm_Data.Models.ChangeRequest ChangeRequest { get; set; }
Student is a namespace but is used like a type
You could rename your Student
class or the Student.Models
namespace. Alternatively, you could qualify the reference like this:
var student = new Student.Models.Student()
{
StudentId = 101,
Name = "James",
Branch = "CSE",
Section = "A",
Gender = "Male"
};
Activity is a namespace but is used like a type
Problem solved. When I was creating new activity to my project in Activity folder, there was a
.Activity
after the namespace.Problem solved by deleting that one.
The (advisable) default in Visual Studio is to keep Folders and namespaces in sync. So the best course here is to rename that folder to Activities
and add that as the tail namespace to all your classes already in that folder.
Activities is also the usual name for that folder in a Droid project.
(C# 'Random' is a namespace but is used like a variable) I don't understand why
Your project's namespace is also Random, change it to some other name,
namespace Random
to
namespace Sample
Related Topics
Swagger UI Web API Documentation Present Enums as Strings
ASP.NET MVC Razor: How to Render a Razor Partial View's HTML Inside the Controller Action
Parsing Visual Studio Solution Files
How to Test If Type Is Primitive
Image Sequence to Video Stream
To Return Iqueryable<T> or Not Return Iqueryable<T>
In C#, What Happens When You Call an Extension Method on a Null Object
Implement Validation for Wpf Textboxes
Replace Only Some Groups with Regex
Custom Method Names in ASP.NET Web API
How to Update a Claim in ASP.NET Identity
How to Parse a String into a Nullable Int
Validation: How to Inject a Model State Wrapper with Ninject
Converting Svg to Png Using C#
How to Read an Excel File in C# Without Using Microsoft.Office.Interop.Excel Libraries