Padding character with string

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Padding { class Program { static void Main(string[] args) { string str = “This is a text”; char padChar = ‘.’; Console.WriteLine(str.PadLeft(25, padChar)); Console.WriteLine(str.PadLeft(2, padChar)); Console.WriteLine(str.PadRight(25, padChar)); Console.WriteLine(str.PadRight(2, padChar)); str = “I am Mahedee hasan. Software Architect, Leadsoft Bangladesh Ltd”; Console.WriteLine((str.PadRight(25, padChar))); Console.WriteLine((str.PadRight(25,padChar)).Substring(0,24)+”…”); Console.ReadKey();

Read More

Iterator Design Pattern with C#

Iterator pattern is a design pattern which is used to traverse aggregate object often called container and access container’s object without exposing it’s underlying representation. Iterator pattern decoupled algorithm from aggregate object or container. In some cases, algorithms are container specific. We often use collection in C# and then we traverse the collection without knowing

Read More

How to send email in ASP.net

ou have to configure SMTP server before sending email from your server. Hope you already know how to configure smtp server. Here is the simple code segment for sending email against a button click. protected void btnSendMail_Click(object sender, EventArgs e) { SmtpClient smtpClient = new SmtpClient(); MailAddress fromAddress = new MailAddress(“mahedee_hasan@leads-bd.com”); //Sender email address MailMessage

Read More