C# program to demonstrate unsafe code using pointers
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to demonstrate the unsafe code using pointers is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we created class UnsafeEx that contains the Main() method, here we used the unsafe keyword with the Main() method to define the unsafe method that can use pointers.
In the Main() method, we created a variable num, which is initialized with 10. Here, we also created an integer pointer then assign the address of the num variable into pointer ptr, and then print value and address using the pointer.