Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

String.GetTypeCode Method

Returns the TypeCode for class String.

[Visual Basic]
Public Overridable Function GetTypeCode() As TypeCode Implements _
   IConvertible.GetTypeCode
[C#]
public virtual TypeCode GetTypeCode();
[C++]
public: virtual TypeCode GetTypeCode();
[JScript]
public function GetTypeCode() : TypeCode;

Return Value

The enumerated constant, TypeCode.String.

Implements

IConvertible.GetTypeCode

Example

[Visual Basic] 
' Sample for String.GetTypeCode()
Imports System

Class Sample
   Public Shared Sub Main()
      Dim str As [String] = "abc"
      Dim tc As TypeCode = str.GetTypeCode()
      Console.WriteLine("The type code for '{0}' is {1}, which represents {2}.", _
                           str, tc.ToString("D"), tc.ToString("F"))
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'The type code for 'abc' is 18, which represents String.
'

[C#] 
// Sample for String.GetTypeCode()
using System;

class Sample 
{
    public static void Main() 
    {
    String str = "abc";
    TypeCode tc = str.GetTypeCode();
    Console.WriteLine("The type code for '{0}' is {1}, which represents {2}.", 
                         str, tc.ToString("D"), tc.ToString("F"));
    }
}
/*
This example produces the following results:
The type code for 'abc' is 18, which represents String.
*/

[C++] 
// Sample for String.GetTypeCode()
#using <mscorlib.dll>
using namespace System;

int main() 
{
    String* str = S"abc";
    TypeCode tc = str->GetTypeCode();
    Console::WriteLine(S"The type code for '{0}' is {1}, which represents {2}.", 
        str, __box(tc)->ToString(S"D"), __box(tc)->ToString(S"F"));
}
/*
This example produces the following results:
The type code for 'abc' is 18, which represents String.
*/

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter 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

String Class | String Members | System Namespace

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft