【问题标题】:How do I use System.Numerics in Mono C# in MonoDevelop?如何在 MonoDevelop 的 Mono C# 中使用 System.Numerics?
【发布时间】:2018-11-22 02:59:17
【问题描述】:

当我的文件顶部有这一行时:

using System.Numerics;

我收到以下错误:

Error CS0234: The type or namespace name 'Numerics' does not exist in the namespace 'System' (are you missing an assembly reference?) (CS0234) (CSharpTests)

我文件顶部的其他using 指令,例如using System;,可以正常工作。

我在 Ubuntu 18.04 64 位上使用 Mono 5.12.0.301 和 MonoDevelop 7.5(内部版本 1255)。

我的第一个想法是框架版本被设置为足够老的东西,以至于没有System.Numerics。在Options -> Build -> General中,我的framework版本默认是4.5,改成最新的4.7.1版本并不能让代码生效:

This answer 发现问题出在框架版本过时,但显然我有足够新的框架版本,对吧?

编辑:好的,根据 SushiHangover 的回答,我可以使用 System.Numerics,但实际上我正在尝试使用 System.Numerics.Vectors,我已将其包含在参考文献中:

但是当我使用using System.Numerics.Vectors; 时,我得到了这个错误:

Error CS0234: The type or namespace name 'Vectors' does not exist in the namespace 'System.Numerics' (are you missing an assembly reference?) (CS0234) (CSharpTests)

【问题讨论】:

    标签: c# namespaces mono monodevelop


    【解决方案1】:

    您需要添加对该程序集的手动引用(以及框架中您需要使用的任何其他程序,默认情况下包含“系统”)

    在解决方案资源管理器中双击项目“参考”:

    【讨论】:

    • 但是using System.Numerics.Vectors; 不起作用,请参阅我的编辑。
    • @AaronFranke “程序集”是 System.Numerics.Vectors.dll,但 Vectors、Vector2 等的“命名空间”是 System.Numerics,而不是 System.Numerics.Vectors 不同的 CIL 程序集,相同的命名空间。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-12
    • 2013-02-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多