Skip to content

Instantly share code, notes, and snippets.

@ProgrammingFire
Created March 23, 2022 13:29
Show Gist options
  • Save ProgrammingFire/d6875d91686b42e58fbeda14d990510a to your computer and use it in GitHub Desktop.
Save ProgrammingFire/d6875d91686b42e58fbeda14d990510a to your computer and use it in GitHub Desktop.
Pointer In C# Like C/C++
// Add <AllowUnsafeBlocks>true</AllowUnsafeBlocks> To Your *.csproj
int variable = 481;
unsafe
{
int* pointer = &variable; // Get The Pointer Of A Variable
Console.WriteLine((int)pointer); // Writes The Pointer
Console.WriteLine(*pointer); // Writes The Value
Console.WriteLine(pointer->ToString()); // Access Properties
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment