您可以通過以下方法獲取字符串的第一個字符:
string str = "Hello"; char firstChar = str[0]; Console.WriteLine(firstChar); // 輸出為 'H'
在C#中,字符串可以像數組一樣使用索引來訪問其中的字符,索引從0開始。因此,您可以使用方括號和索引0來獲取字符串的第一個字符。