blog

How to use C++ code in C#

Why cannot use C++ code in C# directly?

The most remarkable difference between C++ and C# ,i think ,is C++ is unmanaged language rather C# is managed ,which determined you can not write C++ code into the C# code directly,otherwise ,unmanaged code will seems like a runaway train in the managed code

How many ways to use C++ code in C#?

in my opinion ,the ways to use C++ code in C# depends on what you want to call.i just briefly list two type that you want call:

  • C++ function
  • C++ Class
Call C++ function by using Platform Invocation(PInvoke)

PInvoke allows for managed code to call native unmanaged functions implemented as DLLs.this method is ideal for when we have API-like function written in C or C++ that need to be accessed from within a C# program.

NOTE:PInvoke only can be used to Marshall function not to CLass.

The diagram below summarise the PInvake mechanism.

A PInvoke example

Step1 : create Dll project

there is a link aboutcreate DLL project in VS2017

Continue reading “How to use C++ code in C#”

compile Aliyu OSS C++ SDK in windows and install on VS2017

Step0 Downloadthe SDK

there is a official Link about

how to install the SDK in linux and windows

that also include the Download link.

it seems like that the folder which you downlode from github have the suffix of master.

The alibabacloud-oss-cpp-sdk.sln project file is not included in the downloaded SDK package. You must run the cmake command to generate the required project file

step1 intall the cmake

  • Install cmakeOpen cmd to go to the directory that stores the SDK files, create a folder named build, and run cmake to generate the required files, as shown in the following figure
Continue reading “compile Aliyu OSS C++ SDK in windows and install on VS2017”

MySQL

what’s the MySQL

The data relate to each other by nature, e.g., a product belonged to a product category and associated with multiple tags. Therefore, we use the term relational database.

what does SQL contain?

  • Data definition language includes statements that help you define the database and its objects, e.g., tables, views, triggers, stored procedures, etc.
  • Data manipulation language contains statements that allow you to update and query data.
  • Data control language allows you to grant the permissions to a user to access specific data in the database