pre*_*pii 7 delphi pascal lazarus
我已经搜遍了这个.在Delphi/Lazarus中,给定一个位置,我想在不同的字符串中找到该位置的字符.我知道如何找到一个角色的位置.我反过来需要它:给定位置的角色.提前致谢.
Hem*_*ant 12
在Delphi中,可以使用数组表示法对字符串中的字符进行索引.请注意,string中的第一个字符的索引为1.
var
s: string;
c: char;
begin
s := 'Hello';
c := s[1]; //H
end;
Run Code Online (Sandbox Code Playgroud)
小智 5
可以像数组一样访问字符串.
MyString [12]为你提供了字符串中的第12个字符.注意:这是1索引(因为用于保存字符串长度的第0个位置)
示例:
var
MyString : String;
MyChar : Char;
begin
MyString := 'This is a test';
MyChar := MyString[4]; //MyChar is 's'
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14541 次 |
| 最近记录: |