class SmtpSetting
{
public string Host {get; set;}
public string Server {get; set;}
public string Port {get; set;}
}
var smptSettings = new List<SmptSetting>
{
new SmptSetting
{
Host = "mail.ru",
Server = "smtp.mail.ru",
Port = 587
},
new SmptSetting
{
Host = "yahoo.co",
Server = "smtp.yahoo.co",
Port = 465
},
...
}
var currentSmtp = smptSettings.FirstOrDefault(x => x.Host == host);
if(currentSmtp != null)
{
var smtp = new SmtpClient(currentSmtp.Server, currentSmtp.Port);
}
MailMessage
есть настройка IsBodyHtml
, установите ее в true. public interface IRepository<T>
{
T Create();
T Read();
T Update();
T Delete();
}
public class Repository<T> where T : IRepository<T>
{
public static Repository<T> CreateRepository()
{
return new Repository<T>();
}
}
class Program
{
static void Main(string[] args)
{
var repository = Repository<Comment>.CreateRepository();
Console.ReadKey();
}
}
public class Comment : IRepository<Comment>
{
public int Id { get; set; }
public string Name { get; set; }
public Comment Create()
{
return this;
}
public Comment Read()
{
return this;
}
public Comment Update()
{
return this;
}
public Comment Delete()
{
return this;
}
}
static void Main(string[] args)
{
var comments = new[]
{
new Comment { Id = 1, Text = "1" },
new Comment { Id = 2, Text = "2" },
new Comment { Id = 3, Text = "3" },
new Comment { Id = 4, Text = "1" },
new Comment { Id = 5, Text = "2" },
new Comment { Id = 6, Text = "2" },
new Comment { Id = 7, Text = "1" },
new Comment { Id = 8, Text = "4" },
new Comment { Id = 9, Text = "5" },
new Comment { Id = 10, Text = "2" },
};
var result = comments
.GroupBy(x => x.Text)
.SelectMany(x => x.Select(y => y.Id).Skip(1))
.ToArray();
foreach (var id in result)
{
Console.WriteLine($"{id}");
}
Console.ReadKey();
}
class Comment
{
public int Id { get; set; }
public string Text { get; set; }
}
var item = lstTasks.SelectedItem as DataRowView;
if(item == null)
return throw new NullReferenceExeption(nameof(item));
var resultId = item.TryGetValue("id", out int id);
var resultName = item.TryGetValue("name", out string name);
if(resultId && resultName)
DeleteTask(id.ToString(), name);
как я понимаю самой Visual Studio
for(var i = arr.Count - 1; i >= 0; i--)
{
if(arr[i].Name == "Any")
{
arr.RemoveAt(i);
}
}
arr.RemoveAll(x => x.Name == "Any");
arr.Where(x => x.Name != "Any");