Export (0) Print
Expand All

FieldInfo.IsSpecialName Property

Gets a value indicating whether the corresponding SpecialName attribute is set in the FieldAttributes enumerator.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

'Declaration
Public ReadOnly Property IsSpecialName As Boolean

Property Value

Type: System.Boolean
true if the SpecialName attribute is set in FieldAttributes; otherwise, false.

Implements

_FieldInfo.IsSpecialName

Names that begin with or contain an underscore character (_), property accessors, and operator overloading methods are examples of names that might require special treatment by some compilers.

The following example returns a value indicating whether or not the fields in the class contain a SpecialName attribute.

Imports System
Imports System.Reflection
Imports System.ComponentModel.Design
Imports Microsoft.VisualBasic

Class FieldInfo_IsSpecialName

    Public Shared Sub Main()
        Try 
            ' Get the type handle of a specified class. 
            Dim myType As Type = GetType(ViewTechnology)

            ' Get the fields of a specified class. 
            Dim myField As FieldInfo() = myType.GetFields()

            Console.WriteLine(ControlChars.Cr + "Displaying fields that have SpecialName attributes:" + ControlChars.Cr)
            Dim i As Integer 
            For i = 0 To myField.Length - 1
                ' Determine whether or not each field is a special name. 
                If myField(i).IsSpecialName Then
                    Console.WriteLine("The field {0} has a SpecialName attribute.", myField(i).Name)
                End If 
            Next i
        Catch e As Exception
            Console.WriteLine("Exception : {0} ", e.Message.ToString())
        End Try 
    End Sub 'Main
End Class 'FieldInfo_IsSpecialName

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft