Skip to content

[Proposal] Local class declaration #280

@zgxnet

Description

@zgxnet

java supports local class declaration, e.g.
public void Method1(){
class Class1 {
}
}
This is super useful when a function logic is complex, and some data types are not used outside the function. Such local class just solves the problem.
Besides, C++ also supports that.

It is a pity that C# does not support that feature.
And I think this is just a syntax sugar, and does not involve the changes of CLR. So it is an easy feature.

In java, the local class is just treated as an inner class, e.g. MethodName$LocalClassName.
And C# can use the same strategy.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions