unsafe keyword를 사용하면 , C/C++에서 사용하는 pointer를 C#에서도 사용할 수 있다. unsafe keyword를 사용하기 위해서 compile할 때 /unsafe option을 주어야한다. compile할 때 /unsafe option을 주려면 Visual Studio에서 아래와 같이 설정해주면 된다. 참고 : /unsafe (C# Compiler Options) To set /unsafe compiler option in the Visual Studio development environmentOpen the project's Properties page. Click the Build property page. Select the Allow Unsafe Code check bo..
사용환경 : Visual Studio 2017, Windows 10 x64 C#과 C++을 Mixing해서 코딩하는 방법을 알아보자. C++ Class를 C#에서 사용하는 예제를 하나 진행해보자. C++ Class를 만든 후, 그 C++ Class를 사용하는 C++/CLI Class를 만든 다음, C#에서 C++/CLI Class를 사용하는 방식으로 진행하려고 한다. 먼저 Visual Studio에서 “Blank Solution”을 하나 만들자. Solution 이름은 “Hybrid1”으로 하자. Hybrid1 Solution에 “Windows Desktop Wizard”로 Visual C++ Project를 하나 추가한다. Project 이름은 “Native1”으로 하자. Application type..
// [Java] Thread Samplepackage package1; public class Program { public static void main(String[] args) { Thread t1 = new Thread(new A()); Thread t2 = new Thread(new B()); t1.start(); t2.start(); for (int i = 0; i < 10000; i++) { System.out.print("@"); } }} class A implements Runnable { public void run() { for (int i = 0; i < 10000; i++) { System.out.print("."); } }} class B implements Runnable {..
// C# 2.0 Style Threadusing System;using System.Threading; namespace ThreadSample{ class Program { static void Main(string[] args) { // C# 2.0 Style Thread does not use ThreadStart Thread t2 = new Thread(Work); t2.Start(); for (int count = 0; count < Repetitions; count++) { Console.Write('@'); } } static void Work() { for (int count = 0; count < Repetitions; count++) { Console.Write('.'); } } co..
// C# 1.0 Style Threadusing System;using System.Threading; namespace ThreadSample{ class Program { static void Main(string[] args) { // C# 1.0 Style Thread uses ThreadStart ThreadStart ts = new ThreadStart(Work); Thread t1 = new Thread(ts); t1.Start(); for (int count = 0; count < Repetitions; count++) { Console.Write('@'); } } static void Work() { for (int count = 0; count < Repetitions; count++..
Enable SQL Server TCP/IP ProtocolOpen SQL Server Configuration ManagerExpand "SQL Server Network Configuration" and click on "Protocols for MSSQLSERVER"Right click on "TCP/IP" and choose "Enable"Click on "SQL Server Services"Right click on "SQL Server (MSSQLSERVER)" and choose "Restart" Enable TCP/IP Port for SQL Servernetsh advfirewall firewall add rule name=SQLPort dir=in protocol=TCP action=a..
Building Connector/C++ Applications on Windows with Microsoft Visual Studio Directory Structure From https://dev.mysql.com/downloads/connector/cpp/8.0.htmlDownload mysql-connector-c++-8.0.11-windows-x86-64bit.zip fileExtract to $(SolutionDir)connector folder $(SolutionDir)CppConnector$(SolutionDir)connector\include$(SolutionDir)connector\lib64\vs14 Visual Studio Change the build configuration fr..
// Dynamic Memory Allocation : TCHAR *myString #include #include #include #include int _tmain(){ TCHAR *myString; myString = new TCHAR[8]; //_stprintf(myString, _T("%s"), _T("1234567")); wsprintf(myString, _T("%s"), _T("1234567")); _tprintf(_T("String : %s \n"), myString); _tprintf(_T("Length : %d \n"), _tcslen(myString)); delete[] myString; return 0;}
아래는 Composite Format String의 간단한 예제이다.string name = "John"; int age = 20; string gender = "male"; string phone = "012-3456-7890"; Console.WriteLine("First = {0}, Second = {1}, Third = {2}, Fourth = {3}", name, age, gender, phone);이 예제를 보면 {0} {1} {2} {3} 에 무엇이 대입될 것인지 하나씩 찾아보아야 Console.WriteLine 출력문이 이해가 된다. Console.WriteLine 출력문을 Interpolated String으로 바꾸면 아래와 같이 된다.Console.WriteLine($"First = {..
enum type을 iteration하려면 어떻게 해야할까? 예를 들어서 아래와 같이 일주일의 요일이 담긴 emun type인 Days가 있다고 하자.enum Days { Sun, Mon, Tue, Wed, Thu, Fri, Sat }; Days를 iteration하여 아래와 같이 출력하려고 한다. Sun Mon Tue Wed Thu Fri Sat어떻게 해야할까? Enum.GetValues()를 이용하여, 아래와 같이 해주면 된다.Type type = typeof(Days); Array array = Enum.GetValues(type); foreach (var value in array) { Console.WriteLine(value); } Environment.SpecialFolder enum typ..