Console.WindowWidth プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > Console.WindowWidth プロパティの意味・解説 

Console.WindowWidth プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

コンソール ウィンドウの幅を取得または設定します

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Shared Property WindowWidth
 As Integer
Dim value As Integer

value = Console.WindowWidth

Console.WindowWidth = value
public static int WindowWidth
 { get; set; }
/** @property */
public static int get_WindowWidth
 ()

/** @property */
public static void set_WindowWidth
 (int value)

プロパティ
列数で指定されコンソール ウィンドウの幅。

例外例外
例外種類条件

ArgumentOutOfRangeException

WindowWidth プロパティの値または WindowHeight プロパティの値が 0 以下です。

または

WindowHeight プロパティの値と WindowTop プロパティの値を加算し結果が、Int16.MaxValue 以上になっています。

または

WindowWidth プロパティの値または WindowHeight プロパティの値が、現在の画面解像度コンソール フォント利用可能最大ウィンドウの幅または高さより大きくなっています。

IOException

情報読み取り中または書き込み中にエラー発生しました

使用例使用例

SetWindowSize メソッドWindowWidth プロパティ、および WindowHeight プロパティ使用例次に示します。この例を実行すると、コンソール ウィンドウサイズ実際にどのように変化するのかを確認できます

この例は、まず、コンソール ウィンドウの元のサイズ (85 列× 43 行) を表示しユーザーからのキー入力待ちますなんらかのキー押されると、コンソール ウィンドウサイズ半分縮小した後、新しサイズ表示し、再び、ユーザーからのキー入力待ちます最後になんらかのキー押されると、コンソール ウィンドウを元のサイズ戻して終了します

' This example demonstrates the Console.SetWindowSize method,
'                           the Console.WindowWidth property, 
'                       and the Console.WindowHeight property.
Imports System

Class Sample
   Public Shared Sub Main()
      Dim origWidth, width As Integer
      Dim origHeight, height As Integer
      Dim m1 As String =
 "The current window width is {0}, and the " &
 _
                         "current window height is {1}."
      Dim m2 As String =
 "The new window width is {0}, and the new " &
 _
                         "window height is {1}."
      Dim m4 As String =
 "  (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)
   End Sub 'Main
End Class 'Sample
'
'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.
'
'
// 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.

*/
// This example demonstrates the Console.SetWindowSize method,
//                           the Console.WindowWidth property, 
//                       and the Console.WindowHeight property.
using namespace System;
int main()
{
   int origWidth;
   int width;
   int origHeight;
   int 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.

*/
// This example demonstrates the Console.SetWindowSize method,
//                           the Console.WindowWidth property, 
//                       and the Console.WindowHeight property.
import System.*;

class Sample
{
    public static void main(String[]
 args)
    {
        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.get_WindowWidth();
        origHeight = Console.get_WindowHeight();
        Console.WriteLine(m1, System.Convert.ToString(Console.get_WindowWidth())
,
            System.Convert.ToString(Console.get_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(System.Convert.ToString(m2), 
            System.Convert.ToString(Console.get_WindowWidth()),
            System.Convert.ToString(Console.get_WindowHeight()));
        Console.WriteLine(m4);
        Console.ReadKey(true);
        //
        // Step 3: Restore the window to its original size.
        //
        Console.SetWindowSize(origWidth, origHeight);
        Console.WriteLine(System.Convert.ToString(m1),
            System.Convert.ToString(Console.get_WindowWidth()), 
            System.Convert.ToString(Console.get_WindowHeight()));
    } //main
} //Sample
/*
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.

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Console.WindowWidth プロパティ」の関連用語

Console.WindowWidth プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Console.WindowWidth プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS