使用“ System.SysUtils”或“ SysUtils”在德尔福? [英] Use "System.SysUtils" or "SysUtils" in Delphi?

查看:165
本文介绍了使用“ System.SysUtils”或“ SysUtils”在德尔福?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Delphi XE3中,似乎可以使用 System.SysUtils或 SysUtils, Vcl.FileCtrl或 FileCtrl。

In Delphi XE3, it seems that one can use either "System.SysUtils" or "SysUtils", "Vcl.FileCtrl" or "FileCtrl".

I阅读 http://docs.embarcadero中的文章.com / products / rad_studio / delphiAndcpp2009 / HelpUpdate2 / EN / html / devcommon / usingnamespaces_xml.html ,似乎前者被称为完全限定名称空间,而后者是通用名称。但是,如果我理解正确的话,那么在使用这些命名空间下的单元之前,应该添加如下语句:

I read the article in http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/usingnamespaces_xml.html , it seems the former is called full qualified namespace, while the latter is the generic name. But if i understand correct, one should add statements like:

Uses System,Vcl。但是我检查了代码,但是找不到任何 Uses System或 Uses vcl。为什么?

"Uses System, Vcl", before one can use the units under these namespaces. But I check the codes but cannot find any "Uses System" or "Uses vcl". Why?

推荐答案

您正在阅读旧文档,反正阅读了错误的主题。

You are reading old documentation, and reading the wrong topic anyway.

系统 Vcl 实际上是单元作用域名称,与命名空间。 XE2中引入了单位作用域名称,以允许VCL和FMX在不同的作用域下共享常见的单位名称( Vcl.Forms FMX.Forms 等)。迁移到FMX的现有VCL代码(很大程度上)不需要重写,它可以使用只是表格等等,然后神奇地根据项目类型选择正确的范围。

System and Vcl in this context are actually Unit Scope Names, which are similar to, but quite different from, Namespaces. Unit Scope Names were introduced in XE2, to allow VCL and FMX to share common unit names under different scopes (Vcl.Forms vs FMX.Forms, etc). Existing VCL code being migrated to FMX did not (largely) need to be re-written, it could use just Forms, etc and magically pick up the correct scope based on project type. The same does not work with Namespaces.

不必在用途语句是因为它们是在项目级别配置的,默认情况下,大多数VCL项目具有 System Vcl 预配置了作用域名称。

The reason you don't have to explicitly specify Unit Scope Names in uses statements in code is because they are configured at the project level instead, and by default most VCL projects have the System and Vcl scope names pre-configured.

因此,当您使用时,只需 SysUtils FileCtrl 等,编译器会根据项目的单元作用域名称进行检查,最终找到 System.SysUtils Vcl.FileCtrl

So, when you use just SysUtils, FileCtrl etc in your code, the compiler checks them against the project's Unit Scope Names and eventually finds System.SysUtils, Vcl.FileCtrl, etc.

这篇关于使用“ System.SysUtils”或“ SysUtils”在德尔福?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆