Can I use the F # function name designation for C # methods?

In F #, you can name functions using ``Ticked function name notation`` . This is very convenient for naming unit tests.

Is there any way to do this in C #? We can always use Underscored_method_names or PascalMethodNames , but reading it is not so simple.

+7
c # f #
source share
4 answers

No, basically. C # type names and member names cannot contain spaces (and cannot begin with a number). There is support for disambiguating names from reserved keywords ( @ prefix), but that's about it.

When a long name is displayed, DisplayNameAttribute is often used, i.e.

 [DisplayName("My class")] public class MyClass { [DisplayName("Full name")] public string FullName {get;set;} } 
  • but this will not help with your wishes unit test.
+11
source share

Placing actual spaces (ASCII 32) in identifier names is not possible.

However , see this blog post about (ab) using Unicode to insert other code points that look like spaces. The author describes a way to automate this somewhat using hotkeys.

I do not recommend you to do this , as this will cause serious maintainability and debugging problems.

+5
source share

No, this is not a language feature. There is no way to escape a method name so you can use spaces inside it.

+4
source share

What many people do not understand is that you are not limited to English when you called identifiers, classes, members, etc. Yes, you can write your application in Russian or any other language:

 var  = new HtmlForm(); int ワン = 1; 

Maybe you can use something like that for your own purposes?

+1
source share

All Articles