开发者

What does "A type cannot be be used as a standalone statement" error mean?

开发者 https://www.devze.com 2023-04-10 16:58 出处:网络
This is Delphi Prism for .NET. I am running into this error(s), \"A type cannot be be used as a standalone statement\", and I don\'t understand or know why. The compiler is pointing at the lines right

This is Delphi Prism for .NET. I am running into this error(s), "A type cannot be be used as a standalone statement", and I don't understand or know why. The compiler is pointing at the lines right below var keywords.

method ScriptDlgpas.ExecuteStartup;
var
  sname:string;     <------ error raised here
  slist:ArrayList;  <------ error raised here
begin
  sname := basedir+'system\startup.scr';
  if File.Exists(sname) then
  be开发者_开发问答gin
    slist := new ArrayList;
    ExecuteScript(slist);
  end;
end;

The Google Search isn't helping either.

Thanks in advance.


There's probably something above it that doesn't get closed properly.


Try inlining the variables (reducing scope is a good thing btw.):

method ScriptDlgpas.ExecuteStartup;
begin
  var sname := basedir + 'system\startup.scr';
  if File.Exists(sname) then
  begin
    var slist := new ArrayList;
    ExecuteScript(slist);
  end;
end;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号