NamespaceDeclaration Class
Represents a namespace declaration containing types, nested namespaces, and using directives.
public class NamespaceDeclaration : CodeObject, ICommentable, INamespaceDeclarationContainer, ITypeDeclarationContainer, IUsingDirectiveContainerExample
var ns = new NamespaceDeclaration("MyNamespace");
ns.Usings.Add(new UsingDirective("System"));
ns.AddType(new ClassDeclaration("MyClass"));
var code = ns.ToCsharpString();
Assert.StartsWith("namespace MyNamespace", code);
Assert.Contains("using System;", code);
Assert.Contains("class MyClass", code);- Inheritance
CodeObjectNamespaceDeclaration- Implements
Constructors
| Name | Description |
|---|---|
| NamespaceDeclaration() | |
| NamespaceDeclaration(string?) | Initializes a new instance of the NamespaceDeclaration class with the specified name. |
NamespaceDeclaration overloads
NamespaceDeclaration()
NamespaceDeclaration.cspublic NamespaceDeclaration()No documentation is available.
NamespaceDeclaration(string?)
NamespaceDeclaration.csInitializes a new instance of the NamespaceDeclaration class with the specified name.
public NamespaceDeclaration(string? name)Parameters
namestring?- The namespace name.
Properties
| Name | Description |
|---|---|
| CommentsAfter | |
| CommentsBefore | |
| Name | |
| Namespaces | |
| Types | |
| Usings |
CommentsAfter
NamespaceDeclaration.csCommentsBefore
NamespaceDeclaration.csNamespaces
NamespaceDeclaration.cspublic CodeObjectCollection<NamespaceDeclaration> Namespaces { get; }Property value
No documentation is available.
public CodeObjectCollection<TypeDeclaration> Types { get; }Property value
No documentation is available.
Usings
NamespaceDeclaration.cspublic CodeObjectCollection<UsingDirective> Usings { get; }Property value
No documentation is available.