2 444444 8888888
3 99999 7777
4, 55555, 666666
5 99999 7777
.
Text format, the output (also coordinates the serial number of a line)
1, 4
3, 5
CodePudding user response:
Imports System. Text. RegularExpressions
Public Class Form1
Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Dim query=the From y In (
The From x In TextBox1. Lines
Select New With {. V=String. Join (" ", x.S plit (". "ToArray (), StringSplitOptions. RemoveEmptyEntries). Skip (1)), the id=Split (x," ") (0)}
)
Group By y.v Into g=y Group
Where's right mount () & gt; 1
Select String. Join (, "", Select the From g1 In g g1. Id)
TextBox2. Text=String. Join (query, vbCrLf)
End Sub
The End of the Class
CodePudding user response:
using System;
using System.Collections.Generic;
The namespace ConsoleApp1
{
Class Program
{
The static IDictionaryCachedDic=new Dictionary (a);
The static void Main (string [] args)
{
IListList=new List () {
New {Id=1, Value="666666" https://bbs.csdn.net/topics/55555},
New {Id=2, Value="8888888" https://bbs.csdn.net/topics/444444},
New {Id=3, Value="7777" https://bbs.csdn.net/topics/99999},
New {Id=4, Value="666666" https://bbs.csdn.net/topics/55555},
New {Id=5, Value="7777" https://bbs.csdn.net/topics/99999},
};
The foreach (var item in the list)
{
The string key=item. The Value;
String value=(https://bbs.csdn.net/topics/item.Id.ToString);
If (cachedDic. Either ContainsKey (key))
{
[key] cachedDic +=value + ", ";
}
The else
{
CachedDic [key]=value + ", ";
}
}
The Console. ReadLine ();
}
}
}
Can be translated in vb
CodePudding user response:
Sub Main ()Console. WriteLine (" paste text file path: ")
Dim srcP=Console. ReadLine ()
Dim srcTxtEnum=My.Com puter. FileSystem. ReadAllText (srcP). Replace (vbLf, ""). The Split (vbCrLf). Select (Function (s) New With {Key. Id=s.S ubstring (0, 1), the location=s.S ubstring (1, s.L ength - 1). The Replace (Space (1)," ")})
Dim EqualsEnum=srcTxtEnum. GroupBy (Function (s) s.l ocation, Function (x, y) New With {Key. Val=x,. Count=y.C mount}), Where (Function (r) r.c mount & gt; (1). The Select Function (RLT) RLT. Val)
Dim OutTxtList=New List (Of String)
EqualsEnum. ToList. ForEach (Sub (x)
Dim outRow=srcTxtEnum. Where (Function (r) r.l ocation. Equals (x)). Select (Function (r) r.i d)
OutTxtList. Add (String. Join (", ", outRow))
End Sub)
OutTxtList. ForEach (Sub (r) Console. WriteLine (r))
The Console. The Read ()
End Sub
CodePudding user response:
Thank you, everyone a great god, and the code of vb.net write? Just started learning to use, thanks a lot!CodePudding user response: