String.Chars[Int32] Özellik
Önemli
Bazı bilgiler ürünün ön sürümüyle ilgilidir ve sürüm öncesinde önemli değişiklikler yapılmış olabilir. Burada verilen bilgilerle ilgili olarak Microsoft açık veya zımni hiçbir garanti vermez.
public:
property char default[int] { char get(int index); };
public char this[int index] { get; }
member this.Chars(int) : char
Default Public ReadOnly Property Chars(index As Integer) As Char
- index
- Int32
Geçerli dizedeki bir konum.
konumundaki index
nesnesi.
index
bu nesnenin uzunluğuna eşit veya ondan büyük ya da sıfırdan küçük.
Aşağıdaki örnek, bir dizeyi doğrulamak için bu dizin oluşturucuyu bir yordamda nasıl kullanabileceğinizi gösterir.
Console::Write( "Type a string : " );
String^ myString = Console::ReadLine();
for ( int i = 0; i < myString->Length; i++ )
if ( Uri::IsHexDigit( myString[ i ] ) )
Console::WriteLine( "{0} is a hexadecimal digit.", myString[ i ] );
else
Console::WriteLine( "{0} is not a hexadecimal digit.", myString[ i ] );
// The example produces output like the following:
// Type a string : 3f5EaZ
// 3 is a hexadecimal digit.
// f is a hexadecimal digit.
// 5 is a hexadecimal digit.
// E is a hexadecimal digit.
// a is a hexadecimal digit.
// Z is not a hexadecimal digit.
Console.Write("Type a string : ");
string myString = Console.ReadLine();
for (int i = 0; i < myString.Length; i ++)
if(Uri.IsHexDigit(myString[i]))
Console.WriteLine("{0} is a hexadecimal digit.", myString[i]);
else
Console.WriteLine("{0} is not a hexadecimal digit.", myString[i]);
// The example produces output like the following:
// Type a string : 3f5EaZ
// 3 is a hexadecimal digit.
// f is a hexadecimal digit.
// 5 is a hexadecimal digit.
// E is a hexadecimal digit.
// a is a hexadecimal digit.
// Z is not a hexadecimal digit.
open System
printf "Type a string: "
let myString = stdin.ReadLine()
for i = 0 to myString.Length - 1 do
if Uri.IsHexDigit myString[i] then
printfn $"{myString[i]} is a hexadecimal digit."
else
printfn $"{myString[i]} is not a hexadecimal digit."
// The example produces output like the following:
// Type a string: 3f5EaZ
// 3 is a hexadecimal digit.
// f is a hexadecimal digit.
// 5 is a hexadecimal digit.
// E is a hexadecimal digit.
// a is a hexadecimal digit.
// Z is not a hexadecimal digit.
Console.Write("Type a string : ")
Dim myString As String = Console.ReadLine()
Dim i As Integer
For i = 0 To myString.Length - 1
If Uri.IsHexDigit(myString.Chars(i)) Then
Console.WriteLine("{0} is a hexadecimal digit.", myString.Chars(i))
Else
Console.WriteLine("{0} is not a hexadecimal digit.", myString.Chars(i))
End If
Next
' The example produces output like the following:
' Type a string : 3f5EaZ
' 3 is a hexadecimal digit.
' f is a hexadecimal digit.
' 5 is a hexadecimal digit.
' E is a hexadecimal digit.
' a is a hexadecimal digit.
' Z is not a hexadecimal digit.
index
parametresi sıfır tabanlıdır.
Bu özellik, nesnesini parametresi tarafından index
belirtilen konumda döndürürChar. Ancak, bir Unicode karakteri birden Charfazla ile temsil edilebilir.
System.Globalization.StringInfo Nesneleri yerine Char Unicode karakterlerle çalışmak için sınıfını kullanın. Daha fazla bilgi için sınıfa genel bakış bölümündeki "Char Nesneleri ve Unicode Karakterler" bölümüne String bakın.
C# dilinde Chars[] özelliği bir dizin oluşturucudur. Visual Basic'te sınıfın varsayılan özelliğidir String . Dizedeki her Char nesneye aşağıdaki gibi bir kod kullanılarak erişilebilir.
string str1 = "Test";
for (int ctr = 0; ctr <= str1.Length - 1; ctr++ )
Console.Write("{0} ", str1[ctr]);
// The example displays the following output:
// T e s t
let str1 = "Test"
for i = 0 to str1.Length - 1 do
printf $"{str1[i]} "
// The example displays the following output:
// T e s t
Dim str1 As String = "Test"
For ctr As Integer = 0 to str1.Length - 1
Console.Write("{0} ", str1(ctr))
Next
' The example displays the following output:
' T e s t
Ürün | Sürümler |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET geri bildirimi
.NET, açık kaynak bir projedir. Geri bildirim sağlamak için bir bağlantı seçin: