C#代码中的数组减法 [英] array substraction in c# code

查看:672
本文介绍了C#代码中的数组减法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何用c#代码减去两个数组,例如[5,8] [4,6] = [1,2]

Does anyone know how to c# code to substract two arrays like [5,8][4,6]=[1,2]

推荐答案

此示例 [
Check out this example[^], I''m sure you can figure out how to make it work for your requirements.


这似乎很像矩阵运算,除非您创建自己的列表以继承/实现Lift(of Double)等,然后向其添加/重写运算符,否则这不是由defoult实现的...如果您以前没有做过,这是相当复杂的.否则,您可以通过使用for循环来做到这一点...
THis seems to ba a lot like matrix operations, and that is not implemented by defoult, unless you create your own list that inherits/implements Lift(of Double) etc, and add/overrride operators to them... This is reasonabley complicated if you have not done it before. Otherwise you could just do this by using for loops...


请参阅我对问题的评论.看起来像逐元素减法.循环执行.决定如何处理具有不同大小和空值的数组,然后实现所需的算法.问自己另一个问题:如果下次将添加数组怎么办?分配?乘法?您是否需要再问一个问题? :-)

—SA
Please see my comment to the question. It looks like per-element subtraction. Do it in a loop. Decide what to do with the arrays of different sizes and with nulls, and then implement the desired algorithm. Ask yourself another question: what if next time it will be addition of arrays? division? multiplication? Will you need to ask your question again? :-)

—SA


这篇关于C#代码中的数组减法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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