Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Does anyone know how to c# code to substract two arrays like [5,8][4,6]=[1,2]
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-12 12:49pm    
Never tried to strictly define the operation? The sample gives the idea, but does not strictly describe the requirement. If you do it in a mathematically strict manner, most likely, you will see a solution. How will you define it with the arrays of the different lengths?
--SA
bbirajdar 6-Aug-12 12:49pm    
Yes.. I know...
Kenneth Haugland 6-Aug-12 12:56pm    
lol... :)

Check out this example[^], I'm sure you can figure out how to make it work for your requirements.
 
Share this answer
 
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...
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900