在delphi类中声明属性时,是否可能有不同类型的结果?
例:
property month: string read monthGet(字符串) write monthSet(整数);
在这个例子中,我希望,在属性月份,当我:READ,我得到一个字符串; SET,我设置一个整数;
我需要检查字符串是否只包含范围:中的字符'A'..'Z', 'a'..'z', '0'..'9',所以我写了这个函数:
function GetValueTrat(aValue: string): string;
const
number = [0 .. 9];
const
letter = ['a' .. 'z', 'A' .. 'Z'];
var
i: Integer;
begin
for i := 1 to length(aValue) do
begin
if (not(StrToInt(aValue[i]) in number)) or (not(aValue[i] in letter)) then
raise Exception.Create('Non valido');
end;
Result := aValue.Trim;
end;
Run Code Online (Sandbox Code Playgroud)
但是,例如,aValue = 'Hello'该StrToInt函数会引发异常.
我有一个Android项目,我需要使用http调用.
我使用这个简单的代码:
public void onGetClick(View v) {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet("http://www.google.com");
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader
(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) {
Log.d("WM.ALS", line);
}
}
Run Code Online (Sandbox Code Playgroud)
但我找不到HttpClient库.
我将从Apache下载的.jar文件(http://hc.apache.org/downloads.cgi)添加到dir/lib中,并添加到"build.gradle(Module:app)"文件中,我补充说:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.0.1'
compile 'org.apache.httpcomponents:httpcore-4.4.3'
compile 'org.apache.httpcomponents:httpclient-4.5.1'
Run Code Online (Sandbox Code Playgroud)
}
但仍然无法工作..
我该怎么办?
有人可以提供一个如何使用EncodeBase64和DecodeBase64来自库的示例Soap.EncdDecd吗?我正在使用Delphi xe2
delphi ×3
android ×1
arrays ×1
base ×1
decode ×1
delphi-xe2 ×1
encode ×1
integer ×1
java ×1
properties ×1
range ×1
read-write ×1
string ×1