I started using reflection in my project.
When I create a type and I want to specify the TypeAttributes, I have two options:
AnsiClass
and Class
. They are both set to 0 in the enum TypeAttributes
.
public enum TypeAttributes
{
// LPTSTR is interpreted as ANSI.
AnsiClass = 0,
//
// Summary:
// Specifies that the type is a class.
Class = 0,
...
1- What's an ANSI Class
(I noticed that, it's related to the LPTSTR
, but I didn't understood well enough)?
2- What's the difference between an AnsiClass
and a Class
when I use Reflection
.
EDIT
Here's an example of specifying the TypeAttributes in Reflection:
TypeBuilder typeBuilder = mbuilder.DefineType("DataRow", TypeAttributes.Public | TypeAttributes.AnsiClass | TypeAttributes.Class);
I have two options: AnsiClass and Class
No, those are orthogonal. AnsiClass
tells the marshaller that all string properties are to be marshalled as ANSI strings. The other options in that category are:
UnicodeClass
AutoClass
CustomFormatClass
Class
indicates that they type is, well, a class
. The only other option in that group is Interface
. Interestingly, when you look at the attributes of framework types, classes, structs, and interfaces all have the Class
attribute, so I'm not sure what it's used for.
typeof(object).Attributes.Dump();
typeof(int).Attributes.Dump();
typeof(ICloneable).Attributes.Dump();
output:
AutoLayout, AnsiClass, Class, Public, Serializable, BeforeFieldInit
AutoLayout, AnsiClass, Class, Public, SequentialLayout, Sealed, Serializable, BeforeFieldInit
AutoLayout, AnsiClass, Class, Public, ClassSemanticsMask, Abstract
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With