CharEnumerator.GetType() Method in C#


The CharEnumerator.GetType() method in C# is used to get the type of the current instance.

Syntax

public Type GetType();

Let us now see an example to implement the CharEnumerator.GetType() method −

Example

using System;
public class Demo {
   public static void Main(){
      string strNum = "john";
      CharEnumerator ch = strNum.GetEnumerator();
      Console.WriteLine("HashCode = "+ch.GetHashCode());
      Console.WriteLine("Get the Type = "+ch.GetType());
      while (ch.MoveNext())
         Console.Write(ch.Current + " ");
      // disposed
      ch.Dispose();
      // this will show an error since we disposed the object above
      // Console.WriteLine(ch.Current);
   }
}

Output

This will produce the following output −

HashCode = 1373506
Get the Type = System.CharEnumerator
j o h n

Updated on: 05-Nov-2019

22 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements