C++/CLI Syntax part1_在C#中結合C++類別去印出字串的練習

Project setting Let us start to New a project At first , I new a " C# Console Application" program In chinese we say 主控台應用程式 新增一個C# Console Application Add New Project 新加入一個CLR 類別庫 小複習link : http://coolmandiary.blogspot.tw/2016/04/blog-post_30.html Setting the same CPU Configuration Go to the solution properties Both of Debug and release are set x64 Go to the project properties Solution properties --> properties dependencies(專案相依性) Let us try some simple code In the ClassLibrary1.h Block 創建一個對於在託管堆中對象的應用(reference class) 還有這裡的class由於是相依於C#這個project 所以有ref這個字 ref是創建一個位於託管堆上的引用類型, 對應的是value, 它創建一個位於託管棧上的類型, 都由垃圾回收器負責回收內存 以下有附上一些參考連結: 托管类类型的声明 https://msdn.microsoft.com/zh-cn/library/ms235220(VS.80).aspx In the ClassLibrary1.cpp Block The Class has one function test() to print the hello world string on the screen 寫好了這兩份(.cpp及.h檔) 我們先進行建置 ...