gpt4 book ai didi

delphi - 重载 TFormatSettings 和不兼容的类型

转载 作者:行者123 更新时间:2023-12-03 15:45:19 25 4
gpt4 key购买 nike

我有这个程序:

procedure Initialize(out FormatSettings: TFormatSettings);
const
LongDayNamesEx : array [1..7] of string = ('Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato', 'Domenica');
LongMonthNamesEx : array [1..12] of string = ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre');
begin
FormatSettings := TFormatSettings.Create;
with FormatSettings do
begin
LongDayNames := LongDayNamesEx;
LongMonthNames := LongMonthNamesEx;
end;
end;

我收到有关不兼容类型的错误(E2008)。我该如何解决这个问题?我不想使用以下内容:

LongDayNames[1] := 'Lunedì';
LongDayNames[2] := 'Martedì';
...
LongDayNames[7] := 'Domenica';
LongMonthNames[1] := 'Gennaio';
LongMonthNames[2] := 'Febbraio';
...
LongMonthNames[12] := 'Dicembre';

如果不是绝对必要的话。感谢您的帮助。

最佳答案

你可以这样做:

type
TDayNameArray = array[1..7] of string;
const
LongDayNamesEx: TDayNameArray = ('Måndag', 'Tisdag', 'Onsdag', 'Torsdag',
'Fredag', 'Lördag', 'Söndag');
var
fs: TFormatSettings;
begin
TDayNameArray(fs.LongDayNames) := LongDayNamesEx;

关于delphi - 重载 TFormatSettings 和不兼容的类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13474413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com