指定如何进行字符串比较。Specifies how string comparisons are made.


-optioncompare:{binary | text}


可以使用以下两种形式之一指定 -optioncompare:使用二进制字符串比较的 -optioncompare:binary,和使用文本字符串比较的 -optioncompare:textYou can specify -optioncompare in one of two forms: -optioncompare:binary to use binary string comparisons, and -optioncompare:text to use text string comparisons. 默认情况下,编译器使用 -optioncompare:binaryBy default, the compiler uses -optioncompare:binary.

在 Microsoft Windows 中,当前代码页确定二进制排序顺序。In Microsoft Windows, the current code page determines the binary sort order. 典型的二进制排序顺序如下所示:A typical binary sort order is as follows:

A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø

基于由系统的区域设置确定的不区分大小写的文本排序顺序对基于文本的字符串进行比较。Text-based string comparisons are based on a case-insensitive text sort order determined by your system's locale. 典型的文本排序顺序如下所示:A typical text sort order is as follows:

(A = a) < (À = à) < (B=b) < (E=e) < (Ê = ê) < (Z=z) < (Ø = ø)

若要在 Visual Studio IDE 中设置 -optioncompareTo set -optioncompare in the Visual Studio IDE

  1. “解决方案资源管理器” 中选择一个项目。Have a project selected in Solution Explorer. 在“项目”菜单上,单击“属性” 。On the Project menu, click Properties.

  2. 单击“编译” 选项卡。Click the Compile tab.

  3. 修改“Option Compare” 框中的值。Modify the value in the Option Compare box.

以编程方式设置 -optioncompareTo set -optioncompare programmatically

请参阅 Option Compare 语句See Option Compare Statement.


下面的代码编译 ProjFile.vb,并使用二进制字符串比较。The following code compiles ProjFile.vb and uses binary string comparisons.

vbc -optioncompare:binary projFile.vb

请参阅See also