开发者

Why can't I use C# 4 default parameters in Mono?

开发者 https://www.devze.com 2023-01-12 03:17 出处:网络
Mono works fine with my app, but when I try to compile a function like int Yo(int a, int b = 1) { // blah...

Mono works fine with my app, but when I try to compile a function like

int Yo(int a, int b = 1) {
     // blah...
}

It doesn't work, it says that "Default parameter specifiers are not permitted"

According to Mono's website

The Mono C# compiler is considered feature complete for C# 1.0, C# 2.0 and C# 3.0 (ECMA). A preview of C# 4.0 is distributed with Mono 2.6, and a complete C# 4.0 implementation is available with Mono 2.8 or when building Mono from our开发者_StackOverflow trunk source code release.

How can I successfully compile it?


Our C# 4.0 compiler is available as the "dmcs" command as opposed to the "gmcs", "smcs" or "mcs" commands.

After Mono 2.8 we will work towards having a single command line compiler that will let you select the various profiles using a flag, but for now we created different scripts that act as frontends to the API profile/language level that you want to use


Make sure you have gotten Mono 2.8... It has not been released yet, so you will need to download the sources. The git archive page is here.

It is not ready yet, so you will need to get it from source and compile mono yourself before you can use C# 4.0 features and this is only provided that the mono team has in fact finished writing these features into their compiler.

0

精彩评论

暂无评论...
验证码 换一张
取 消