作者a901531456 (Jeff)
看板C_Sharp
标题[问题] 新手不会debug
时间Mon Feb 18 13:02:27 2013
小弟我刚学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
1F:推 q90036:你把 ImageToBuffer这支 method写到 Main里面了 所以会错 02/18 13:45
2F:→ a901531456:所以必须在主程式呼叫? 02/18 14:23
3F:推 cloudsan:你把一个method写到另外一个method里,独立出来,在main 02/18 17:58
4F:→ cloudsan:呼叫他 02/18 17:58