KO CSharp Operator Pointer - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
ะฃะบัะฐัะฝััะบะฐ ยท ะ ัััะบะธะน ยท English ยท Deutsch ยท Franรงais ยท Italiano ยท Espaรฑol ยท ็น้ซไธญๆ ยท ๆฅๆฌ่ช ยท ํ๊ตญ์ด
ํฌ์ธํฐ๋ฅผ ์ฌ์ฉํ ์์
ํธ๋๋ถ C# ยท ์ค์ฉ ๊ฐ์ด๋
&๋ ์ฃผ์๋ฅผ ๊ฐ์ ธ์ค๊ณ , *๋ ํฌ์ธํฐ์ ์ด๋ฆ์ ๋ณ๊ฒฝํ๊ณ , -> ํฌ์ธํฐ ๋์์ ๋ฉค๋ฒ์ ์ก์ธ์คํฉ๋๋ค. ์์ ํ์ง ์์ ๋ฉ๋ชจ๋ฆฌ ์๋ช ์ค์๊ฐ ํ์ํฉ๋๋ค.
๊ฐ๋จํ ์์ (Example.cs)
์ด ์์ ๋ฅผ Example.cs๋ก ๋ฐ๋ก ์ ์ฅํ๊ณ ์ด ํ์ด์ง์ ๋ค๋ฅธ ์์ ์ ๋
๋ฆฝ์ ์ผ๋ก ์คํํ์ธ์.
Example.cs:
// PROJECT-EXAMPLE
unsafe
{
int value = 3;
int* pointer = &value;
*pointer = 7;
System.Console.WriteLine(value);
}
ํ๋ก์ ํธ์์ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>๋ฅผ ํ์ฑํํ์ธ์. ํฌ์ธํฐ๋ ํ์๋ ๋ฒ์ ๋ด์์๋ง ์ ํจํฉ๋๋ค.
๊ฒฐ๊ณผ:
7
ํต์ฌ๋ก
Type* pointer = &value; / *pointer / pointer->Member
์์ 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
unsafe { int value = 3; int* pointer = &value; *pointer = 9; Console.WriteLine(value); }
}
}
์์ 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
unsafe { Point value = new() { X = 2 }; Point* pointer = &value; pointer->X += 5; Console.WriteLine(value.X); }
}
}
public struct Point { public int X; }
๊ณต์ ์ถ์ฒ: Microsoft ํ์ต.