我正在使用OpenPop.net尝试解析来自给定收件箱中所有电子邮件的链接.我找到了这个方法来获取所有消息:
public static List<OpenPop.Mime.Message> FetchAllMessages(string hostname, int port, bool useSsl, string username, string password)
{
// The client disconnects from the server when being disposed
using (Pop3Client client = new Pop3Client())
{
// Connect to the server
client.Connect(hostname, port, useSsl);
// Authenticate ourselves towards the server
client.Authenticate(username, password);
// Get the number of messages in the inbox
int messageCount = client.GetMessageCount();
// We want to download all messages
List<OpenPop.Mime.Message> allMessages = new List<OpenPop.Mime.Message>(messageCount);
// Messages are numbered in the interval: …Run Code Online (Sandbox Code Playgroud) 我使用以下代码将我的文本文件加载到哈希集中.
HashSet<string> hashs = new HashSet<string>(File.ReadLines("textFile.txt"));
Run Code Online (Sandbox Code Playgroud)
我想知道是否有任何简单的方法从它获得随机线?
让我们假设textFile.txt包含10行,我想随机化并抓住其中一条现有行.
我有两个像这样的哈希集:
HashSet<string> log1 = new HashSet<string>(File.ReadLines("log1.txt"));
HashSet<string> log2 = searcher(term);
Run Code Online (Sandbox Code Playgroud)
我怎么比较这两个?
我想确保它log2不包含任何条目log1.换句话说,我想删除所有(如果有的话)log1内部的项目log2.