find and solve || findandsolve.com
Please wait.....

C# String GetTypeCode()

In the C# GetTypeCode() method is used to get type code of string. It returns type code of string class and It does not take any parameter.

Syntax

public TypeCode GetTypeCode() 

Parameters

It does not take any parameter.

Return value: This method return an enumerated constant.

C# String GetTypeCode() Method Example

Exampe 1
using System.Data;
public class Program
{
 public static void Main()
 {       // variables
        string str = "FindAndSolve";
        int a = 9;
        // get the TypeCode by
        // using GetTypeCode() method
        Console.WriteLine("The TypeCode for {0}': {1}",
                              str, str.GetTypeCode());
        Console.WriteLine("The TypeCode for '{0}': {1}",
                                    a, a.GetTypeCode());
 }
}

Output

The TypeCode for FindAndSolve': String

The TypeCode for '9': Int32

Example 2

using System.Data;
public class Program
{
 public static void Main()
 {       // variables
          string str = "Hello find ans solve";
          Console.WriteLine(str.GetTypeCode());
 }
}

Output

String

Example 3

using System;
public class Program
{
 public static void Main()
 {
  // given string
     String str = "FindAndSolve";
    // get the TypeCode of the given String
    // using GetTypeCode() method
    TypeCode getTypecode = str.GetTypeCode();
    Console.WriteLine("TypeCode for '{0}': {1}, Which means it represents a {2}.",
                                          str, getTypecode.ToString("D"), getTypecode.ToString("F"));
 }
}