Skip to content

File local types C# 11.0code generation

Allow types to be scoped to the file they are defined in.

In order to avoid collisions with other types (such as when generating code) you can prefix a type with the file keyword to indicate it can only be referenced from the file it is defined in.

Code ​

csharp
file class CantBeSeenOutside
{
}
csharp
internal class CantBeSeenOutside234456aze
{
}

Notes ​

  • A file type can't appear in the signature of a member of a non-file type, as it would then be visible outside the file

More information ​

Powered by Intracia