Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which C# type names are special?

Tags:

c#

Under what inputs does IsSpecialName return true? From my brief research I've found that property accessors and operator overloads have special names, alongside any type with a name which contains an underscore. Can anyone give me a complete description of cases in which a type name is special?

like image 642
laurie Avatar asked Nov 05 '13 11:11

laurie


People also ask

What is %d in C programming?

In C programming language, %d and %i are format specifiers as where %d specifies the type of variable as decimal and %i specifies the type as integer. In usage terms, there is no difference in printf() function output while printing a number using %d or %i but using scanf the difference occurs.

What does %c mean in C?

%d is used to print decimal(integer) number ,while %c is used to print character . If you try to print a character with %d format the computer will print the ASCII code of the character.


2 Answers

The CLI specification as published in ECMA-335 is a decent source for info like this. Search the document for rtspecialname (names that are special to the CLR) and specialname (names that are special to tools. The specialname attribute is turned on for rtspecialnames. Giving these hits:

  • The underlying value__ field of an enumerated type
  • The getter and setter accessor methods of a property
  • The add, remove and fire accessors methods of an event
  • Operator overloads
  • The .ctor method of a class, the constructor
  • The .cctor method of a class, the static constructor
like image 103
Hans Passant Avatar answered Oct 19 '22 01:10

Hans Passant


First of all IsSpecialName does not take any input. Also the property of Type is not really applicable to property accessors or operator overloads, since it's a property of a Type and operators/accessors are not types. This is despite what the MSDN article might tell you.

I would venture a guess that it returns true when the correspondent TypeAttribute is SpecialName. You can refer to ECMA 335 Standard to find out what is supposed to be marked as a Special Name. Incidentally, you'll learn that it's things like operators and property accessors. This explains where the confusion in the MSDN article can come from.

I believe that on Type this property is implemented mostly for the benefit of compilers and such that could require additional (as compared to what ECMA 335 mandate) special name handling. (Which could differ from compiler to compiler).

like image 37
Andrew Savinykh Avatar answered Oct 19 '22 00:10

Andrew Savinykh