alpha1, я сомневаюсь, что в массиве ba лежит именно null-terminated строка. а во-вторых
| Код | using System; using System.Text; using System.Runtime.InteropServices; public partial class _Default: System.Web.UI.Page { [DllImport("Project2.dll")] unsafe public static extern char DeCrypt(char *str); protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { // Create two different encodings. Encoding ascii = Encoding.ASCII; Encoding unicode = Encoding.Unicode; // Convert the string into a byte[]. byte[] unicodeBytes = unicode.GetBytes(unicodeString); // Perform the conversion from one encoding to the other. byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes); char[] charArray = ascii.GetString(asciiBytes).ToCharArray(); unsafe { fixed(char *str = charArray) //Вот тут вылетает ошибка: "Не удается неявно преобразовать тип "byte*" в "char*"" Response.Write(DeCrypt(str)); } } }
|
опять повторюсь, что в charArray наверняка лежит НЕ null-terminated срока, как того требует C/C++ |