Search code examples
xamarin.android

How to delete unwanted lines in an array


I use the following method by OCR to transfer the written values ​​to the array.
The problem I have is I want to ignore any line containing a word or letters less than 13 length.

SparseArray items = detections.DetectedItems;
StringBuilder strBuilder = new StringBuilder();

for (int i = 0; i < items.Size(); ++i)
{
    istring s = ((TextBlock)items.ValueAt(i)).Value;
    int length = S.Length;
    if (length > 13)
    {
        strBuilder.Append(result);
        strBuilder.Append("\n");
    }
}

Solution

  • You can remove the line by items.Remove(i); if length > 13:

    for (int i = 0; i < items.Size(); ++i)
    {
        istring s = ((TextBlock)items.ValueAt(i)).Value;
        int length = S.Length;
        if (length > 13)
        {
            items.Remove(i);
    
            strBuilder.Append(result);
            strBuilder.Append("\n");
        }
    }