Given public String(char*) why we cannot use the following statement?
string str = new string("aaa");
Error 1
The best overloaded method match for
‘string.String(char*)’ has some
invalid
arguments C:\temp\ConsoleApplication2\ConsoleApplication2\Program.cs 19 26 ConsoleApplication2
Error 2
Argument 1: cannot convert from
‘string’ to
‘char*’ C:\temp\ConsoleApplication2\ConsoleApplication2\Program.cs 19 37 ConsoleApplication2
Simply use:
You do not need to
newa string.“aaa” is a string. It is not a
char *.char *is used withunsafecode.