What are the "accepted literal types"?

  • Thread starter Thread starter Pascual ataeda
  • Start date Start date
P

Pascual ataeda

Hello,

According to the MSDN documentation, FieldInfo.GetValue throws a
NotSupportedException if “A field is marked literal, but the field does
not have one of the accepted literal types”.

What are the accepted literal types? What are the unaccepted literal
types?



*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
 
What are the accepted literal types?

That would be the types that you can write consts for (17.3 in the C#
language spec)

bool, char, float, double, byte, short, int, long, string,
any enum type plus the null value for any reference type.

C# also supports writing decimal consts, but IIRC that's implemented
as a static readonly field with a custom attribute, and I'm not sure
if the FieldInfo class supports that or not.



Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top