![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Reflection - Difference between DateTime.MaxValue andDecimal.MaxValue I just noticed that, when using intellisense, the DateTime.MaxValue field has a static property icon whereas the Decimal.MaxValue field has a constant property icon. However, when looking at the PropertyInfo data displayed by using reflection against the types, I can see no inherent differences between the properties. How does microsoft determind this difference? Or, how can I determine the difference using reflection? |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Reflection - Difference between DateTime.MaxValue and Decimal.MaxValue Joey Fontaine wrote: Quote: > I just noticed that, when using intellisense, the DateTime.MaxValue > field has a static property icon whereas the Decimal.MaxValue field > has a constant property icon. However, when looking at the > PropertyInfo data displayed by using reflection against the types, I > can see no inherent differences between the properties. > fields (so I assume you're talking about FieldInfo). Both are public static initonly fields. Quote: > How does microsoft determind this difference? Or, how can I determine > the difference using reflection? associated with the decimal field (but not the DateTime field). You can verify this yourself by declaring const decimal i = 0.0; static readonly decimal i = 0.0; These produce the same declarations except for the first one having an extra attribute, and VS shows different icons. -- J. |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Reflection - Difference between DateTime.MaxValue andDecimal.MaxValue On Oct 13, 1:08*pm, Jeroen Mostert <jmost...@xxxxxx> wrote: Quote: > Joey Fontaine wrote: Quote: > > I just noticed that, when using intellisense, the DateTime.MaxValue > > field has a static property icon whereas the Decimal.MaxValue field > > has a constant property icon. However, when looking at the > > PropertyInfo data displayed by using reflection against the types, I > > can see no inherent differences between the properties. > Neither DateTime.MaxValue nor Decimal.MaxValue are properties, they're > fields (so I assume you're talking about FieldInfo). Both are public static > initonly fields. > Quote: > > How does microsoft determind this difference? Or, how can I determine > > the difference using reflection? > This is a guess, but VS might be using the DecimalConstantAttribute > associated with the decimal field (but not the DateTime field). You can > verify this yourself by declaring > > * *const decimal i = 0.0; > * *static readonly decimal i = 0.0; > > These produce the same declarations except for the first one having an extra > attribute, and VS shows different icons. > > -- > J. IsStatic properties of the FieldInfo class along with the CustomConstantAttribute, DecimalConstantAttribute and DateTimeConstantAttribute located in the System.Runtime.CompilerServices namespace in order to determine if a FieldInfo object is a constant. Thanks! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Question on Reflection | .NET General | |||
| Rounding of a [datetime] | PowerShell | |||
| bug in string<->datetime conversion? | PowerShell | |||
| How to use [datetime]::now properly? | PowerShell | |||
| RC2 DateTime casting | PowerShell | |||