The first problem is that
DisplayHelloFromDLL
is an instance method of the
test
class - which means that just like the C# equivalent:
public class test
{
public void test()
{
printf("This is default constructor");
}
void DisplayHelloFromDLL(char * name, int appId)
{
printf("Hello from DLL !\n");
printf("Name is %s\n", name);
printf("Length is %d \n", appId);
}
}
You cannot call it without referencing an instance of the
test
class:
text t = new test();
t.DisplayHelloFromDLL(str, str.Length);
To call it without an instance, the method needs to be
static
:
Static Keyword in C++[
^] or not a part of a class at all.
And there is the real problem: you can't use C++ classes in C#, unless the DLL is built for CLI - and then you can just add a reference to it and use it as if it was in C#.