Created
February 29, 2016 06:32
-
-
Save olto/30600de14fae7f18a072 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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