using Serilog; public class MyClass { private ILogger logger; public MyClass() { this.logger = new LoggerConfiguration() .WriteTo.File("log.txt") .CreateLogger(); } public void MyMethod() { // do something this.logger.Information("MyMethod executed successfully."); } }
using MailKit.Net.Smtp; using MailKit.Security; using MimeKit; public class MyClass { public void SendEmail(string recipient, string subject, string body) { var message = new MimeMessage(); message.From.Add(new MailboxAddress("Sender Name", "[email protected]")); message.To.Add(new MailboxAddress(recipient, recipient)); message.Subject = subject; message.Body = new TextPart("plain") { Text = body }; using (var client = new SmtpClient()) { client.Connect("smtp.example.com", 587, SecureSocketOptions.StartTls); client.Authenticate("[email protected]", "password"); client.Send(message); client.Disconnect(true); } } }In conclusion, C# Component is a powerful library that simplifies the development of applications by providing reusable components. The package library used in an application depends on the specific component being used.