C# Partial methods

Hello all!
I would like to prevent some code diseases and tell you about new C# syntax idea of partial methods.
You could write code like this in one class:
class Example {
public void Main(){
Foo(data);
}

partial void Foo(data1){statement1;}
partial void Foo(data2){statement2;}
}

Then, you maybe interested in some Roslyn made manipulation:
Thread a = new Thread((data1) => {statement1;});
Thread b = new Thread((data2) => {statement2;});
a.Start();
b.Start();

P.S. The main purpose is to make simple parallelism use and more safe control under the hood. The system could implement more faster and correct syntax manipulation via Task, ThreadPool, TPL, etc.

This issue has been extensively discussed on the proper place: https://github.com/dotnet/csharplang

1 Like
.NET Foundation Website | Blog | Projects | Code of Conduct