NamespaceDeclaration Class

Represents a namespace declaration containing types, nested namespaces, and using directives.

Example

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
CodeObject NamespaceDeclaration
Implements

Constructors

NameDescription
NamespaceDeclaration()
NamespaceDeclaration(string?)Initializes a new instance of the NamespaceDeclaration class with the specified name.

NamespaceDeclaration overloads

NamespaceDeclaration()

NamespaceDeclaration.cs
public NamespaceDeclaration()

No documentation is available.

NamespaceDeclaration(string?)

NamespaceDeclaration.cs

Initializes a new instance of the NamespaceDeclaration class with the specified name.

public NamespaceDeclaration(string? name)
Parameters
name string?
The namespace name.

Properties

NameDescription
CommentsAfter
CommentsBefore
Name
Namespaces
Types
Usings
public CommentCollection CommentsAfter { get; }

Property value

CommentCollection

No documentation is available.

public CommentCollection CommentsBefore { get; }

Property value

CommentCollection

No documentation is available.

public string? Name { get; set; }

Property value

string?

No documentation is available.

public CodeObjectCollection<NamespaceDeclaration> Namespaces { get; }

No documentation is available.

public CodeObjectCollection<TypeDeclaration> Types { get; }

No documentation is available.

public CodeObjectCollection<UsingDirective> Usings { get; }

No documentation is available.