I'd use
Linq[
^]. See:
Dim lines As String() = New String(){"APPLE", "APPLE", "MANGO", "BANANA", "BANANA", "APPLE", "MANGO"}
Dim dups = lines. _
Select(Function(l, i) New With{i, l}). _
GroupBy(Function(x) x.l). _
Select(Function(grp) New With _
{ _
.Value=grp.Key, _
.Lines = String.Join(";", grp.Select(Function(x) x.i)) _
}). _
ToList()
string[] lines = {"APPLE", "APPLE", "MANGO", "BANANA", "BANANA", "APPLE", "MANGO"};
var dups = lines
.Select((l, i) => new {i, l})
.GroupBy(x => x.l)
.Select(grp => new
{
Value=grp.Key,
Lines = string.Join(";", grp.Select(x=> x.i))
})
.ToList();
dups
variable holds:
Value Lines
APPLE 0;1;5
MANGO 2;6
BANANA 3;4