2011-12-30 65 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

相关问题