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

C#
file class CantBeSeenOutside
{
}
C#
public class CantBeSeenOutside234456aze
{
}

More information