Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am using CSML for matrix multiplication.
at certain points i have to retrieve a specific indexed value from the matrix but i am unable to retrieve it.

the method i am using is:

public static int matrix2int(Matrix m, int i, int j)
{
return (int)m.Row(i).Values[j-1];//casting Arraylist to int
}

the error being generated is can not cast Arraylist to int.
can the developer of CSML help me out how to do it.


waiting for your answer
Posted

try it this way"

return (int)(m.Row(i).Values[j-1]);

Essentailly, cast the value in the ArrayList as an int instead of casting the ArrayList as an int.
 
Share this answer
 
v2
Innayat Ullah wrote:
can the developer of CSML help me out how to do it.


And you think this person, whoever he is, is going to appear from nowhere and see your message?
 
Share this answer
 
Well you may need to do some error handling then...

If the value returned from m.Row(i).Values[j-1] always an int? If not, then the code I gave will error, because we assume that the value is an int when we cast it.

You might want to try Int32.Parse(m.Row(i).Values[j-1]) or Int32.TryParse().

Figure out if there is some exception being thrown, figure out what the value is in the matrix, etc.
 
Share this answer
 
Thanks for the answer but it isn't working either
 
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