Click here to Skip to main content
15,886,640 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a list like AncillariesList = new ObservableCollection<controldomain>();

and it contains a value named Lineno.So if the list contains some 20 values and the last value is 1200, i want to increment from the last value when the user click on add button.How can i achieve this??
Posted
Updated 27-Jan-15 0:57am
Comments
nagendrathecoder 27-Jan-15 7:07am    
Are those 20 values so far in that list are in increasing order or in random sequence?
chandra sekhar 27-Jan-15 7:09am    
They are in the increasing order.

1 solution

If list has values in increasing order then you can do something like this:
C#
int lastVal = AncillariesList[AncillariesList.Count - 1];

now while adding new member, you can use
C#
++lastVal;
 
Share this answer
 
Comments
chandra sekhar 27-Jan-15 7:16am    
int lastVal = AncillariesList[AncillariesList.Count - 1]; This says cannot implicitly convert type controlDomain to int.
nagendrathecoder 27-Jan-15 7:19am    
This must be returning some class object.
Use classobject.Lineno property.
For e.g: AncillariesList[AncillariesList.Count - 1].Lineno;
chandra sekhar 27-Jan-15 8:58am    
Thanks that worked!!
nagendrathecoder 27-Jan-15 9:01am    
Great

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