C# Program to Demonstrate the Pointer as a Data Member

Hello friend you may have many doubts about C# Program to Demonstrate the Pointer as a Data Member We hope this article fills in all the doubts in the article. Let’s get back to the article.

C# Program to Demonstrate the Pointer as a Data Member

C# Program to Demonstrate the Pointer as a Data Member

//C# program to demonstrate the pointer as a data member.

using System;
unsafe class UnsafeEx
{
    int* p;
    int val;

    public UnsafeEx(int v)
    {
        val = v;
        p = &v;

        Console.WriteLine("Val : " + *p);
    }
    static void Main(string[] args)
    {
        UnsafeEx U1 = new UnsafeEx(10);
        UnsafeEx U2 = new UnsafeEx(20);
        UnsafeEx U3 = new UnsafeEx(30);
    }
}
Val : 10
Val : 20
Val : 30
Press any key to continue . . .

Final Words

C# Program to Demonstrate the Pointer as a Data Member the article will satisfy all your doubts.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment