看板 C_Sharp 關於我們 聯絡資訊
小弟我剛學C#,有段程式看不出問題出在哪,是否有高手願意提點? 以下附上程式,也附上問題 1>C:\Users\99325113\Desktop\ConsoleApplication1\ConsoleApplication1\Program.cs(13,10,13,11): error CS1513: 必須是 } 1>C:\Users\99325113\Desktop\ConsoleApplication1\ConsoleApplication1\Program.cs(40,1,40,2): error CS1022: 必須是型別或命名空間定義,或檔案結尾 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Drawing; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // /// <summary> // 將 Image 轉換為 Byte 陣列。 // </summary> // <param name="ImgPath">圖片路徑 。</param> public static byte[] ImageToBuffer(string ImgPath) { byte[] _ImageBytes; if (File.Exists(ImgPath)) { Image _Image = Image.FromFile(ImgPath); MemoryStream ms = new MemoryStream(); _Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); _ImageBytes = ms.GetBuffer(); ms.Dispose(); _Image.Dispose(); } else { _ImageBytes = null; } return _ImageBytes; } } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 203.64.84.134
q90036:你把 ImageToBuffer這支 method寫到 Main裡面了 所以會錯 02/18 13:45
a901531456:所以必須在主程式呼叫? 02/18 14:23
cloudsan:你把一個method寫到另外一個method裡,獨立出來,在main 02/18 17:58
cloudsan:呼叫他 02/18 17:58