static void Main()
{
// Create a Unicode String with 5 Greek Alpha characters
String szGreekAlpha = new String('/u0319', 5);
// Create a Unicode String with a Greek Omega character
String szGreekOmega1 = new String(new char[] { '/u03A9', '/u03A9', '/u03A9' });
String szGreekOmega = new String(new char[] { '/u03A9', '/u03A9', '/u03A9' }, 2, 1);
String szGreekLetters = String.Concat(szGreekOmega, szGreekAlpha, szGreekOmega.Clone());
Console.WriteLine(szGreekAlpha);
Console.WriteLine(szGreekOmega1);
Console.WriteLine(szGreekOmega);
// Examine the result
Console.WriteLine(szGreekLetters);
// The first index of Alpha
int ialpha = szGreekLetters.IndexOf('/u0319');
// The last index of Omega
int iomega = szGreekLetters.LastIndexOf('/u03A9');
Console.WriteLine("The Greek letter Alpha first appears at index " + ialpha +
" and Omega last appears at index " + iomega + " in this String.");
}
结果:
?????
ΩΩΩ
Ω
Ω?????Ω
The Greek letter Alpha first appears at index 1 and Omega last appears at index
6 in this String.