I am developing an app which in which I am storing barcodes and names in a single list item.
For example, one list item may be:
"501377267837 Apples"
What I want to do is first of all check if the barcode that has been scanned already exists in the list and if it does I want to seperate the barcode from the name.
For example:
501377267837
Chicken
I was going to use String.Split but how can I then insert these seperate strings into different textviews?
Also, will the Contains() method identify the barcode even though the item contains more than just that barcode?
How can I achieve this?
Thanks
Use a list of model instead string .
The model has two properties called Barcode
and Name
.
You could retrieve the list and find out the item whose Barcode is identical .
public class Item
{
public string Barcode { get; set; }
public string Name { get; set; }
}
List<Item> list = xx;
foreach(Item item in list)
{
if(item.Barcode is "Specific barcode")
{
//handle your logic
}
}