Skip to content

Instantly share code, notes, and snippets.

@olto
Created February 29, 2016 06:32
Show Gist options
  • Select an option

  • Save olto/30600de14fae7f18a072 to your computer and use it in GitHub Desktop.

Select an option

Save olto/30600de14fae7f18a072 to your computer and use it in GitHub Desktop.
using System;
namespace test
{
class Program
{
static void Main(string[] args)
{
CentrerLeTexte("Du texte");
CentrerLeTexte("Encore du texte");
Console.ReadLine();
}
private static void CentrerLeTexte(string texte)
{
// Méthode pour centrer du texte dans la console
int nbEspaces = (Console.WindowWidth - texte.Length) / 2;
Console.SetCursorPosition(nbEspaces, Console.CursorTop);
Console.WriteLine(texte);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment