C# program to check a specified type is a pointer or not

Here, we are going to learn how to check a specified type is a pointer or not in C#?
Submitted by Nidhi, on October 30, 2020

Here, we will check a specified type is a pointer or not using the IsPointer property.

Program:

The source code to check a specified type is a pointer or not is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.

//C# program to check a specified type is a pointer or not. 

using System;
using System.Reflection;

class Program
{
    static void Main()
    {
        int[] Arr = new int[10];

        if (Arr.GetType().IsPointer == true)
        {
            Console.WriteLine("Arr is a pointer");
        }
        else
        {
            Console.WriteLine("Arr is not a pointer");
        }
    }
}

Output:

Arr is not a pointer
Press any key to continue . . .

Explanation:

In the above program, we created a class Program that contains the Main() method. The Main() method is the entry point for the program. Here we check the specified type is a pointer or not using the IsPointer property and then printed the appropriate message on the console screen.

C# Basic Programs »


ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.