String.Length プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)


Length プロパティは、このインスタンス内の Char オブジェクトの数を返します。Unicode 文字の数ではありません。これは、1 つの Unicode 文字が複数の Char で表されることがあるためです。おのおのの Char ではなくおのおのの Unicode 文字を対象に処理を行うには、System.Globalization.StringInfo クラスを使用します。

' Sample for String.Length Imports System Class Sample Public Shared Sub Main() Dim str As String = "abcdefg" Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length) Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length) End Sub 'Main End Class 'Sample ' 'This example produces the following results: '1) The length of 'abcdefg' is 7 '2) The length of 'xyz' is 3 '
// Sample for String.Length using System; class Sample { public static void Main() { string str = "abcdefg"; Console.WriteLine("1) The length of '{0}' is {1}", str, str.Length); Console.WriteLine("2) The length of '{0}' is {1}", "xyz", "xyz".Length); } } /* This example produces the following results: 1) The length of 'abcdefg' is 7 2) The length of 'xyz' is 3 */
// Sample for String::Length using namespace System; int main() { String^ str = "abcdefg"; Console::WriteLine( "1) The length of '{0}' is {1}", str, str->Length ); Console::WriteLine( "2) The length of '{0}' is {1}", "xyz", ((String^)"xyz")->Length ); } /* This example produces the following results: 1) The length of 'abcdefg' is 7 2) The length of 'xyz' is 3 */
// Sample for String.Length import System.*; class Sample { public static void main(String[] args) { String str = "abcdefg"; Console.WriteLine("1) The length of '{0}' is {1}", str, (Int32)str.get_Length()); Console.WriteLine("2) The length of '{0}' is {1}", "xyz", (Int32)"xyz".get_Length()); } //main } //Sample /* This example produces the following results: 1) The length of 'abcdefg' is 7 2) The length of 'xyz' is 3 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からString.Length プロパティを検索する場合は、下記のリンクをクリックしてください。

- String.Length プロパティのページへのリンク