简体   繁体   English

CS1503 无法将矩阵转换为 MatrixOrder

[英]CS1503 Cannot convert Matrix to MatrixOrder

I'm quite new to C# programming.我对 C# 编程很陌生。 I would like to run a simple test in MVS for Matrix calculation code as attached.我想在 MVS 中为所附的矩阵计算代码运行一个简单的测试。

However I obtained the following errors:但是我得到了以下错误:

1) Error CS1503 Argument 2: cannot convert from 'System.Drawing.Drawing2D.Matrix' to 'System.Drawing.Drawing2D.MatrixOrder' 1) 错误 CS1503 参数 2:无法从“System.Drawing.Drawing2D.Matrix”转换为“System.Drawing.Drawing2D.MatrixOrder”

2) Error CS0019 Operator '*' cannot be applied to operands of type 'Matrix' and 'Matrix' 2) 错误 CS0019 运算符“*”不能应用于“矩阵”和“矩阵”类型的操作数

I had tried looking for solutions, but couldn't resolve this errors.我曾尝试寻找解决方案,但无法解决此错误。

Target Framework: .Net Framework 4.7.2 Output Type: Console Application目标框架:.Net Framework 4.7.2 输出类型:控制台应用程序

Please advise.请指教。 Thank You.谢谢你。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using System.Drawing.Drawing2D;

namespace Project2

{
    public class MatrixCalculation
    {
        static void Main()
        {
        }

        private void MultiplicationExample()
        {
            Matrix matrix1 = new Matrix(5, 10, 15, 20, 25, 30);
            Matrix matrix2 = new Matrix(2, 4, 6, 8, 10, 12);

            // matrixResult is equal to (70,100,150,220,240,352) 
          Matrix matrixResult = Matrix.Multiply(matrix1, matrix2);

            // matrixResult2 is also
            // equal to (70,100,150,220,240,352) 
            Matrix matrixResult2 = matrix1 * matrix2;
        }
    }
}

It is because you are using a System.Drawing.Drawing2D.Matrix instead of a System.Windows.Media.Matrix .这是因为您使用的是System.Drawing.Drawing2D.Matrix而不是System.Windows.Media.Matrix

The System.Drawing.Drawing2D.Matrix.Multiply method takes one or two parameters. System.Drawing.Drawing2D.Matrix.Multiply方法采用一两个参数。 The first one being a Matrix and the optional second one a MatrixOrder .第一个是Matrix ,可选的第二个是MatrixOrder

Remove this line:删除这一行:

using System.Drawing.Drawing2D;

If the error persists, the you're probably referencing the wrong assembly.如果错误仍然存​​在,则您可能引用了错误的程序集。

If you're using Visual Studio如果您使用的是 Visual Studio

  1. Right click your project's references右键单击您项目的引用
  2. Click on ' Add Reference '单击“添加引用
  3. Search for WindowsBase and select it搜索WindowsBase并选择它

If you are using the namespace System.Drawing.Drawing2D , you could do the multiplication like the following:如果您使用命名空间System.Drawing.Drawing2D ,您可以执行如下乘法:

matrix1.Multiply(matrix2); //matrix1 will have the result.

For reference: https://docs.microsoft.com/en-us/dotnet/api/system.drawing.drawing2d.matrix.multiply?view=netframework-4.8供参考: https : //docs.microsoft.com/en-us/dotnet/api/system.drawing.drawing2d.matrix.multiply?view=netframework-4.8

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法将字符串转换为 generic.enumerable 字符串 (CS1503) - Cannot convert string to generic.enumerable string (CS1503) CS1503 参数 1:无法从 'string' 转换为 'string[*,*]' - CS1503 Argument1: cannot convert from 'string' to 'string[*,*]' C#无法从void转换为bool - CS1503 - C# Cannot convert from void to bool - CS1503 CsvWriter、CS1503 参数 2:无法转换 CultureInfo - CsvWriter, CS1503 Argument 2: cannot convert CultureInfo CS1503 参数 1:无法从“Poc.Core.Player”转换为“Poc.Interfaces.IScheduleable” - CS1503 Argument 1: cannot convert from 'Poc.Core.Player' to 'Poc.Interfaces.IScheduleable' CS1503 C#参数1:无法从“ System.IO.Stream”转换为“ char []” - CS1503 C# Argument 1: cannot convert from 'System.IO.Stream' to 'char[]' 错误CS1503:参数“#2”无法将“对象”表达式转换为类型“ UnityEngine.Vector3” - error CS1503: Argument `#2' cannot convert `object' expression to type `UnityEngine.Vector3' CS1503:参数 1:无法从“方法组”转换为“Action,bool&gt;” - CS1503: Argument 1: cannot convert from 'method group' to 'Action,bool>' CS1503:参数 2:无法从 &#39;System.Action[*,*,*] 转换为 System.Action[]&#39; C# 2022 - CS1503: Argument 2: Cannot convert from 'System.Action[*,*,*] to System.Action[]' C# 2022 错误 CS1503 - 无法从 Microsoft.Extensions.Configuration.IConfigurationSection 转换为 System.Action&lt;&gt; - Error CS1503 - Cannot convert from Microsoft.Extensions.Configuration.IConfigurationSection to System.Action<>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM