Stack & Heap

Unity3D/C# 2018. 8. 30. 19:17
반응형



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp_20180830
{
    class Program
    {
        public static void Main(string[] args)
        {
            Inventory inventory = new Inventory();
            int i = 10;
 
            unsafe
            {
                TypedReference tr1 = __makeref(i);
                IntPtr ptr1 = **(IntPtr**)(&tr1);
                Console.WriteLine(ptr1);
 
                int a = 20;
                int* ptr = &a;
 
                int* ptr2 = ptr;
 
                Console.WriteLine($"Value of a is {*ptr}");
                Console.WriteLine($"Address of a is {(int)ptr2}");
 
            }
 
            Console.ReadKey();
        }
    }
}
 
cs




https://gooroo.io/GoorooTHINK/Article/17038/Pointers-and-Unsafe-Code-in-C-everything-you-need-to-know/25066#.W4fKZc4zbMo



반응형

'Unity3D > C#' 카테고리의 다른 글

Visual Studio Code 에서 C# 콘솔 프로젝트 하기  (0) 2018.12.28
SOLID (객체 지향 설계)  (0) 2018.09.03
Console.ReadLine  (0) 2018.08.22
float 의 기본값은 0.0f  (0) 2018.08.21
string의 기본값 null  (0) 2018.08.21
: