Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Type.GetElementType() Method in C#
The Type.GetElementType() method in C# is used to return the Type of the object encompassed or referred to by the current array, pointer or reference type.
Syntax
Following is the syntax −
public abstract Type GetElementType ();
Example
Let us now see an example to implement the Type.GetElementType() method −
using System;
public class Demo {
public static void Main(){
string[] arr = {"tom", "amit", "kevin", "katie"};
Type t1 = arr.GetType();
Type t2 = t1.GetElementType();
Console.WriteLine("Type = "+t2.ToString());
}
}
Output
This will produce the following output −
Type = System.String
Example
Let us now see another example to implement the Type.GetElementType() method −
using System;
public class Demo {
public static void Main(){
Type t1 = typeof(int[,,,, ]);
Type t2 = t1.GetElementType();
Console.WriteLine("Type = "+t2.ToString());
}
}
Output
This will produce the following output −
Type = System.Int32
Advertisements