using System; namespace HL2 { class Program { static void Main(string[] args) { unsafe { static void change(int* a, int* b) { int tmp = *a; *a = *b; *b = tmp; } //value //address //int x = 10; //Console.WriteLine(x); //int* myPoint = &x; //Console.WriteLine($"Address is: {(long)myPoint}"); //Console.WriteLine($"Value is: {*myPoint}"); //*myPoint = 12; //Console.WriteLine($"MyPoint Value is: {*myPoint}"); //Console.WriteLine($"x Value is: {x}"); int a = 10; int b = 12; Console.WriteLine($"OLD a: {a} b: {b}"); change(&a, &b); Console.WriteLine($"NEW a: {a} b: {b}"); } } } }
@gamesieukho4788 Жыл бұрын
Sao chatgpt nó bảo việc sử dụng con trỏ trong Unsafe code không làm giảm hoặc loại bỏ những rủi ro và hạn chế của nó. Thực tế, việc sử dụng con trỏ trong Unsafe code thậm chí còn tăng thêm các rủi ro liên quan đến quản lý bộ nhớ và tính bảo mật🥹