2011-12-30 28 views
3

我是C#的新手,不知道它的語法。但是我對其他語言(Java,C++)有所瞭解。 我下載了GLWidget project並試圖建立它。但是我在這行錯誤CS0501(同{ get; set; }):必須聲明一個body,因爲它沒有標記爲抽象或外部(CS0501)

namespace Gtk 
{ 
    [ToolboxItem(true)] 
    public class GLWidget : DrawingArea, IDisposable 
    { 
     IGraphicsContext graphicsContext; 
     static int graphicsContextCount; 

     /// <summary>Use a single buffer versus a double buffer.</summary> 
     [Browsable(true)] 
     public bool SingleBuffer { get; set; } 

     /// <summary>Color Buffer Bits-Per-Pixel</summary> 
     public int ColorBPP { get; set; } 

     /// <summary>Accumulation Buffer Bits-Per-Pixel</summary> 
     public int AccumulatorBPP { get; set; } 

     /// <summary>Depth Buffer Bits-Per-Pixel</summary> 
     public int DepthBPP { get; set; } 

     /// <summary>Stencil Buffer Bits-Per-Pixel</summary> 
     public int StencilBPP { get; set; } 

     /// <summary>Number of samples</summary> 
     public int Samples { get; set; } 

     /// <summary>Indicates if steropic renderering is enabled</summary> 
     public bool Stereo { get; set; } 

     IWindowInfo windowInfo; 

爲什麼這傢伙這樣做呢?這是一個微不足道的錯誤嗎?

+0

你用什麼版本的.NET編譯它?得到;組;語法並不總是存在。 – 2011-12-30 21:35:03

+0

您的編譯器必須瞭解.NET 3.5(或4.0?)語法。即使面向.NET 2.0,Visual Studio 2010也可以做到這一點。 – 2011-12-30 21:35:58

+3

這與.NET版本無關。這是一個C#版本問題。 – 2011-12-30 21:37:17

回答

6

您使用的是哪種版本的編譯器?此代碼使用的是C#3.0及更高版本中提供的Auto-Implemented Properties

因爲我假設MonoDevelop使用Mono compiler'mcs'(和varients),所以這個問題取決於Mono的版本。 Mono 2.6支持C#3.0(4.0的預覽版)。也許你只需要升級Mono和/或MonoDevelop。

+0

我怎麼說我是C#中的新手。我下載了Monodevelopment IDE,就是這樣。 – itun 2011-12-31 01:01:00

+0

如何知道什麼是.NET版本?編譯器在哪裏?我使用Windows。 – itun 2011-12-31 01:07:37

-2

自動屬性是在c#3.0中引入的,因此請嘗試更改框架版本。

+1

Jonathon Reinhart在上面的評論中指出,這不是框架版本的問題,而是編譯器版本的問題。 – phoog 2011-12-30 22:28:26

相關問題