在C#中,为什么int.TryParse不能解析分号(但double.TryParse可以)?
int i1 = 13579;
string si1 = i1.ToString("N0"); //becomes 13,579
int i2 = 0;
bool result1 = int.TryParse(si1, out i2); //gets false and 0
double d1 = 24680.0;
string sd1 = d1.ToString("N0"); //becomes 24,680
double d2 = 0;
bool result2 = double.TryParse(sd1, out d2); //gets true and 24680.0
Run Code Online (Sandbox Code Playgroud)
???
如何指定在Delphi中调用哪个基类的重写方法?
比方说,像这样的继承行:TObject - > ... SomeMoreBaseClass ... - > ParentClass - > MyClass
假设ParentClass没有Create(),但它有一个Create(int = 0).这样当你调用ParentClass.Create()时,它实际上调用ParentClass.Create(0)
现在,在MyClass的构造函数Create()中,如果我调用"inherited;",我发现我没有得到ParentClass.Create(0),而是得到基类的.Create()甚至是TObject.
那么,我怎样才能调用ParentClass.Create()?
最简单的是"继承Create(0)",但它感觉不够"正确".
(在我的情况下,ParentClass实际上是System.Generics.Collections.TDictionary)
type
TParentClass = class
public
constructor Create(n:Integer = 0);
end;
TDerivedClass = class(TParentClass)
public
constructor Create; // Note: no parameters
end;
constructor TDerivedClass.Create;
begin
// inherited; // this calls TObject.Create, not TParentClass.Create(0);
inherited Create(0);
end;
Run Code Online (Sandbox Code Playgroud)