Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get last values from arrays

I am checking one line of code from my project

if ( (test == 0) &&
     lenght.Matches(new Version(Convert.ToInt64(version))) )

Whenever i debugged i am getting currentVersion as a constant value of 18 digit number,but the result i wanted is last exisitng datas version

i am getting 'length' as using the following code

length.Version = (long)data.Version.Rows[0]["Version"];

So i suspect it is always taking Rows arrays first value, how can i change this code so that it will give the last value of arrays

like image 438
shanethomson11 Avatar asked Dec 10 '25 09:12

shanethomson11


1 Answers

Using LINQ-expression

currentVersion.Version = (long)m_spodata.DataVersion.Rows.Last()["Version"];  

Using Rows.Count property

currentVersion.Version = 
  (long) m_spodata.DataVersion.Rows[m_spodata.DataVersion.Rows.Count - 1]["Version"]; 
like image 161
VMAtm Avatar answered Dec 12 '25 22:12

VMAtm