- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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.GetTypeArray() Method in C#
The Type.GetTypeArray() method in C# is used to get the types of the objects in the specified array.
Syntax
Following is the syntax −
public static Type[] GetTypeArray (object[] args);
The arg argument is an array of objects whose types to determine.
Example
Let us now see an example to implement the Type.GetTypeArray() method −
using System; using System.Reflection; public class Demo { public static void Main(){ Object[] obj = new Object[5]; obj[0] = 10.20; obj[1] = 20; obj[2] = 30; obj[3] = 40; obj[4] = "tom"; Type[] type = Type.GetTypeArray(obj); Console.WriteLine("Types..."); for (int i = 0; i < type.Length; i++) Console.WriteLine(" {0}", type[i]); } }
Output
This will produce the following output −
Types... System.Double System.Int32 System.Int32 System.Int32 System.String
Example
Let us now see another example to implement the Type.GetTypeArray() method −
using System; using System.Reflection; public class Demo { public static void Main(){ Object[] obj = new Object[5]; obj[0] = 100m; obj[1] = 20.98; obj[2] = 30.788m; obj[3] = 40; obj[4] = "jack"; Type[] type = Type.GetTypeArray(obj); Console.WriteLine("Types..."); for (int i = 0; i < type.Length; i++) Console.WriteLine(" {0}", type[i]); } }
Output
This will produce the following output −
Types... System.Decimal System.Double System.Decimal System.Int32 System.String
Advertisements