在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
http://docwiki.embarcadero.com/RADStudio/Berlin/en/Simple_Types_(Delphi)#Enumerated_TypesDelphi Compiler Changes for XE7String-Like Operations Supported on Dynamic Arrays
var
A: array of integer;
B: TBytes = [1,2,3,4]; //Initialization can be done from declaration
begin
...
A:=[1,2,3]; // assignation using constant array
A:=A+[4,5]; // addition - A will become [1,2,3,4,5]
...
end;
I. The Insert function inserts a dynamic array at the beginning at the position index. It returns the modified array. var
A: array of integer;
begin
...
A:=[1,2,3,4];
Insert(5,A,2); // A will become [1,2,5,3,4]
...
end;
II. The Delete function eliminates elements from a dynamic array and returns the modifed array: var
A: array of integer;
begin
...
A:=[1,2,3,4];
Delete(A,1,2); //A will become [1,4]
...
end;
III. The Concat function can be used to put together two different dynamic arrays: A := Concat([1,2,3],[4,5,6]); //A will become [1,2,3,4,5,6]
class function
TGUID = record D1: Cardinal; D2: Word; D3: Word; D4: array[0..7] of Byte; class operator Equal(const Left, Right: TGUID): Boolean; class operator NotEqual(const Left, Right: TGUID): Boolean; class function Empty: TGUID; static; class function Create(const Data; BigEndian: Boolean = False): TGUID; overload; static; class function Create(const Data: array of Byte; AStartIndex: Cardinal; BigEndian: Boolean = False): TGUID; overload; static; end; 对应的c++builder里就是__classmethod __classmethod System::UnicodeString __fastcall Fun();
TStringHelper = record helper for string public const Empty = '';
private type
字符串数组for in 类似foreach用法 http://www.cnblogs.com/huangjacky/archive/2009/12/09/1620612.html arrStr: array of string = ['aaa', 'bbb', 'ccc'];for i := 0 to Length(arrStr) - 1 do arrStr[i]; 或者 for astr in arrStr do ListBox1.Items.Add(astr); 抽象方法
abstract
纯虚方法
function GetFlags: TGestureEngineFlags; virtual; abstract;
抽象方法也叫纯虚方法
abstract 抽象方法是那些在类中声明但未实现的虚拟方法或动态方法。
抽象方法的实现推延到后裔类中。
声明抽象方法必需在指示字virtual或dynamic之后使用abstract。 所谓抽象方法,首先必须是虚拟的或动态的,其次在它所在类中只能声明而 override 重载,实现多态。实现或覆盖virtual, dynamic, abstract的声明
overload 再定义一个名称相同但参数不同的函数. (调用时自动根据参数选择)。 有抽象方法的类就是抽象类。
http://blog.csdn.net/xinzheng_wang/article/details/6058643
这个语法比较好,面向对象编程,某些场合代替了枚举,有几种选项。
TTableJSon = class
c++builder不行 class PASCALIMPLEMENTATION TTableJSon : public System::TObject { typedef System::TObject inherited; private: #define TTableJSon_cstFieldType L"FieldType" #define TTableJSon_cstFieldName L"FieldName" #define TTableJSon_cstFieldSize L"FieldSize" #define TTableJSon_cstJsonType L"JsonType" #define TTableJSon_cstRequired L"Required" #define TTableJSon_cstFieldIndex L"FieldIndex" #define TTableJSon_cstCols L"Cols" #define TTableJSon_cstData L"Data" void __fastcall test(void); public: /* TObject.Create */ inline __fastcall TTableJSon(void) : System::TObject() { } /* TObject.Destroy */ inline __fastcall virtual ~TTableJSon(void) { } }; 用#define转换,但是不能通过对象的实例类访问 TTableJSon *js;
旧语法 函数名相同参数不同的重载 overload;
子类继承父类,重写父类的方法 override;
jgdm: array [0 .. 20] of AnsiChar; PByte 函数 fun1(para: byte; result: PByte): 调用1 ucbuf: array [0 .. 3] of BYTE; fun1(para,@ucbuf); 或者 pb: TBytes;SetLength(pb, 3);
fun1(para,@pb); byte数组转为integer
it := Integer(ucbuf); int转为16进制字符 strtemp := Format('0x%02X ', [it]);
c#函数的byte[]参数 getCardInfo( byte[] Data); delphi为 array of byte;
泛型数组
SetLength(lParams, Length(paramInfos)); 代替了传统的
array of integer
枚举类型 type days=(sun,mon,tue,wed,thu,fri,sat);
构造函数 constructor
property WorkareaRect: TRect read GetWorkareaRect; property WaitTime default 255; property Scaled: Boolean read GetScaled write SetScaled stored IsForm default True;
SLineBreak是换行符 System.pas Result := ''
字符串下标从0开始
Accesses individual characters in this zero-based string. The Chars property is read-only. MyString: String; for I:= 0 to MyString.Length - 1 do Write(MyString.Chars[I]);
判断dataset是否编辑状态dsEditModes dsEditModes = [dsEdit, dsInsert, dsSetKey];
Tokyo 10.2.2 Firemonkey下的模态窗口解决方案。 FMX.DialogService TDialogService.MessageDialog(); TDialogService.ShowMessage('hello'); procedure TForm2.btnShowMessageClick(Sender: TObject); begin TDialogService.ShowMessage('您点选了OK按钮', ShowMessageCloseMethod); end; procedure TForm2.ShowMessageCloseMethod(const AResult: TModalResult); var alvi : TListViewItem; begin alvi := ListView1.Items.Add; alvi.Text := DateTimeToStr(Now); alvi.Detail := '关闭了ShowMessage对话盒!'; end;
string 字符串下标 一直以来是从1开始 astr.Chars[0]; FMX下提供了从0开始的字符 delphi的TStringHelper提供了该方法。但是c++builder没有。 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论