C#XNA Xbox,在这种情况下,可选参数不是可选参数 [英] C# XNA Xbox, in this case optional parameters are not optional

查看:89
本文介绍了C#XNA Xbox,在这种情况下,可选参数不是可选参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当在Xbox上使用时,显然可选参数在C#Xna中不起作用,在编译过程中声明了非替代性.

Apparently optional parameters won't work in C# Xna when used on the Xbox, there non suportedness is stated during compilation.

我遇到这样的情况:

func(float? a = null, int? b = null)

具有大量的thease可选参数,默认为未定义"值,为null.这种情况是必需的.

With large numbers of thease optional parameters that default to the "undefined" value, null. This situation is required.

在上面的简化示例中,可以将其解包,尽管这不是可选参数所允许的:

In the simplified example above this can be unwrapped, although this isn't as optional parameters allow:

func()
func(float? a)
func(int? b)
func(float? a, int? b)

但是,对于大量参数而言,这是不切实际的.

However with large numbers of parameters this isn't practical.

不允许使用参数定义的某些组合,并且会导致通过函数抛出我抛出参数异常的路径,另一些导致根据参数的值发生各种不同的事情.这类似于具有相同名称但不相同的函数之间的多态性.

Some combinations of parameters definedness isn't permitted and results in paths through the function where I throw argument exceptions, others result in various different things occurring depending on the values of the parameters. This is similar to polymorphism between functions with the same name but is not the same.

我可以替代地并且很可能是最实际地要求所有参数.

I could alternatively, and probbably most practically, require all the parameters instead.

func(float? a, int? b)

然后这样打电话:

func(null, 4)

第一个未定义的地方.

有没有办法在Xbox上的C#XNA中启用可选参数?

Instead of using one of the above bodges, is there a way to enable optional parameters in C# XNA on Xbox?

推荐答案

我当然已经在XBOX上使用可选参数运行了,但是需要对构建设置进行一些调整.我记得它不适用于WP7.

I've certainly run on the XBOX with optional parameters, but it required some tweaking of the build settings. From what I recall it will not work with WP7 however.

我认为这可能与所使用的语言版本有关.

I think it might have been related to the Language Version being used.

查看以下链接:

http://msdn.microsoft.com/en-us/library/ff827884.aspx

http://forums.create.msdn.com/forums/p/54007/327944.aspx

这篇关于C#XNA Xbox,在这种情况下,可选参数不是可选参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆