x


Default Parameter Specifiers Are Not Permitted

I started editing a new C# script in MonoDevelop, and pressed the "Build Project Assembly" button (F7). This caused it to now go into another C# library package I've had working for a while, and drop the following error dozens of times on function definitions with optional parameters:

Default parameter specifiers are not permitted (C50241)

The errors are only thrown in MonoDevelop. When you save it and switch to the Unity editor, it compiles and runs the code fine, as I've been using that package's scripts for weeks. I'm thus only now discovering that MonoDevelop doesn't approve, possibly because it's the first time I hit F7 on a C# file instead of JS, so I presume that it compiles all scripts of only the language of the script you're editing.

Google has it that C# only started accepting default parameter specifiers after version 4.0. So is there a discrepancy between the assembler of Unity and that of MonoDevelop, such that the former accepts post-C#-4.0 conventions and the latter doesn't?

more ▼

asked Oct 13 '11 at 04:11 PM

blitzen gravatar image

blitzen
180 22 31 34

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

The latest version of mono supports this just fine. If you're using Mono Develop 2.8x and you're still getting this problem you might want to make sure you're actually using the .NET 4.0 compiler.

To do this change the setting in the Project options:

alt text alt text

more ▼

answered Jan 09 '12 at 05:55 AM

feanix gravatar image

feanix
91 2 3 3

Indeed mine was set to 3.5 by default. Good one.

Feb 12 '12 at 05:34 PM blitzen

Is there a way to make this change permanent? It seems to reset this sometimes :s

Jan 15 at 04:57 PM The Oddler

I can confim this. .NET 3.5's alternate to default parameters is member overloading. As far as changing it back I think Unity is doing that. You shouldn't have a problem if you build in Unity even though MonoDevelop may be giving you an error.

Member Overloading - http://msdn.microsoft.com/en-us/library/vstudio/ms229029%28v=vs.100%29.aspx

Jan 16 at 09:10 PM doublethink

True, no problems in Unity. Though it's still annoying in monobehaviour. I mainly get this when using other libraries, and it's a pain to change all their default-parameter stuff to member overloading :P

Jan 16 at 09:29 PM The Oddler
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4148
x377
x61
x29

asked: Oct 13 '11 at 04:11 PM

Seen: 4767 times

Last Updated: Jan 16 at 09:29 PM