using System.Xml.Serialization;
public static void Main()
string sGuest = "Nasreddine";
Console.WriteLine(new String('*', width));
Console.WriteLine(Center(sGuest, width));
Console.WriteLine(Center("is invited to the wedding of:",width));
Console.WriteLine(Center(sBride + " and " + sGroom, width));
Console.WriteLine(Center("On Saturday 17 July 2016 at 2:00pm", width));
Console.WriteLine(new String('*', width));
public static string Center(string str, int length)
if (string.IsNullOrWhiteSpace(str))
return new String(' ',length);
if (str.Length >= length)
var halfDiff = (length - str.Length)/2.0;
return string.Format("{0}{1}", new String(' ', (int) Math.Floor(halfDiff)), str) ;