Re: C# как передать массив?
От: Lloyd Россия  
Дата: 31.10.10 23:57
Оценка:
Здравствуйте, alexparser, Вы писали:

A>
A>public static bool SendFileToPrinter(string szPrinterName)
A>            {
A>                bool bSuccess = false;
A>                char[] array1 = new char[64];
A>                bSuccess = SendBytesToPrinter(szPrinterName, array1, 64); <<--- (1)
A>                return bSuccess;
A>            }

A>public static bool SendStringToPrinter(string szPrinterName, string szString)
A>            {
A>                IntPtr pBytes;
A>                Int32 dwCount;
A>                // How many characters are in the string?
A>                dwCount = szString.Length;
A>                // Assume that the printer is expecting ANSI text, and then convert
A>                // the string to ANSI text.
A>                pBytes = Marshal.StringToCoTaskMemAnsi(szString);
A>                // Send the converted ANSI string to the printer.
A>                SendBytesToPrinter(szPrinterName, pBytes, dwCount); <<--- (2)
A>                Marshal.FreeCoTaskMem(pBytes);
A>                return true;
A>            }
A>


A>-------------------------------------------------------------------------------------

A>Error 1 The best overloaded method match for 'Project.MainWnd.RawPrinterHelper.SendBytesToPrinter(string, System.IntPtr, int)' has some invalid arguments C:\Project\MainWnd.cs 220 28 Project
A>Error 2 Argument '2': cannot convert from 'char[]' to 'System.IntPtr' C:\Project\MainWnd.cs 220 62 Project

Это так и должно быть, что в одном случае вы вызываете SendBytesToPrinter с char[] в кач-ве 2-го параметра, а во втором случае — с IntPtr ?
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.