Type.IsAnsiClass Property
Gets a value indicating whether the string format attribute AnsiClass is selected for the Type.
[Visual Basic] Public ReadOnly Property IsAnsiClass As Boolean [C#] public bool IsAnsiClass {get;} [C++] public: __property bool get_IsAnsiClass(); [JScript] public function get IsAnsiClass() : Boolean;
Property Value
true if the string format attribute AnsiClass is selected for the Type; otherwise, false.
Remarks
The StringFormatMask selects the string format attributes. The string format attributes enhance interoperability by defining how strings should be interpreted.
Example
[Visual Basic, C#, C++] The following example gets the field information and checks for the AnsiClass attribute.
[Visual Basic] Imports System Imports System.Reflection Imports Microsoft.VisualBasic Public Class MyClass1 Protected myField As String = "A sample protected field." End Class 'MyClass1 Public Class MyType_IsAnsiClass Public Shared Sub Main() Try Dim myObject As New MyClass1() ' Get the type of MyClass1. Dim myType As Type = GetType(MyClass1) ' Get the field information and the attributes associated with MyClass1. Dim myFieldInfo As FieldInfo = myType.GetField("myField", BindingFlags.NonPublic Or BindingFlags.Instance) Console.WriteLine(ControlChars.NewLine + "Checking for AnsiClass attribute for a field." + ControlChars.NewLine) ' Get and display the name, field, and the AnsiClass attribute. Console.WriteLine("Name of Class: {0} " + ControlChars.NewLine + "Value of Field: {1} " + ControlChars.NewLine + "IsAnsiClass = {2}", myType.FullName, myFieldInfo.GetValue(myObject), myType.IsAnsiClass) Catch e As Exception Console.WriteLine("Exception: {0}", e.Message.ToString()) End Try End Sub 'Main End Class 'MyType_IsAnsiClass [C#] using System; using System.Reflection; public class MyClass { protected string myField = "A sample protected field." ; } public class MyType_IsAnsiClass { public static void Main() { try { MyClass myObject = new MyClass(); // Get the type of the 'MyClass'. Type myType = typeof(MyClass); // Get the field information and the attributes associated with MyClass. FieldInfo myFieldInfo = myType.GetField("myField", BindingFlags.NonPublic|BindingFlags.Instance); Console.WriteLine( "\nChecking for the AnsiClass attribute for a field.\n"); // Get and display the name, field, and the AnsiClass attribute. Console.WriteLine("Name of Class: {0} \nValue of Field: {1} \nIsAnsiClass = {2}", myType.FullName, myFieldInfo.GetValue(myObject), myType.IsAnsiClass); } catch(Exception e) { Console.WriteLine("Exception: {0}",e.Message); } } } [C++] #using <mscorlib.dll> using namespace System; using namespace System::Reflection; public __gc class MyClass { protected: String* myField; public: MyClass() { myField = "A sample protected field"; } }; int main() { try { MyClass* myObject = new MyClass(); // Get the type of the 'MyClass'. Type* myType = __typeof(MyClass); // Get the field information and the attributes associated with MyClass. FieldInfo* myFieldInfo = myType->GetField(S"myField", static_cast<BindingFlags>(BindingFlags::NonPublic|BindingFlags::Instance)); Console::WriteLine(S"\nChecking for the AnsiClass attribute for a field.\n"); // Get and display the name, field, and the AnsiClass attribute. Console::WriteLine(S"Name of Class: {0} \nValue of Field: {1} \nIsAnsiClass = {2}", myType->FullName, myFieldInfo->GetValue(myObject),__box( myType->IsAnsiClass)); } catch (Exception* e) { Console::WriteLine(S"Exception: {0}", e->Message); } }
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework
See Also
Type Class | Type Members | System Namespace | TypeAttributes | IsUnicodeClass | IsAutoClass