|
Cet article a fait l'objet d'une traduction automatique. Déplacez votre pointeur sur les phrases de l'article pour voir la version originale de ce texte. Informations supplémentaires.
|
Traduction
Source
|
Console.WindowWidth, propriété
Espace de noms : System
Assembly : mscorlib (dans mscorlib.dll)
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | |
| IOException |
// This example demonstrates the Console.SetWindowSize method, // the Console.WindowWidth property, // and the Console.WindowHeight property. using System; class Sample { public static void Main() { int origWidth, width; int origHeight, height; string m1 = "The current window width is {0}, and the " + "current window height is {1}."; string m2 = "The new window width is {0}, and the new " + "window height is {1}."; string m4 = " (Press any key to continue...)"; // // Step 1: Get the current window dimensions. // origWidth = Console.WindowWidth; origHeight = Console.WindowHeight; Console.WriteLine(m1, Console.WindowWidth, Console.WindowHeight); Console.WriteLine(m4); Console.ReadKey(true); // // Step 2: Cut the window to 1/4 its original size. // width = origWidth/2; height = origHeight/2; Console.SetWindowSize(width, height); Console.WriteLine(m2, Console.WindowWidth, Console.WindowHeight); Console.WriteLine(m4); Console.ReadKey(true); // // Step 3: Restore the window to its original size. // Console.SetWindowSize(origWidth, origHeight); Console.WriteLine(m1, Console.WindowWidth, Console.WindowHeight); } } /* This example produces the following results: The current window width is 85, and the current window height is 43. (Press any key to continue...) The new window width is 42, and the new window height is 21. (Press any key to continue...) The current window width is 85, and the current window height is 43. */
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (rôle principal du serveur non pris en charge), Windows Server 2008 R2 (rôle principal du serveur pris en charge avec SP1 ou version ultérieure ; Itanium non pris en charge)
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.