This means that, by default, all comparison methods you can invoke on a Generic List, Array, or Collection will use Binary compare whether you intend it or not, as are methods in the above list that you invoke on Strings. Here’s a mostly complete list of methods that ignore Option Compare. This includes a wide variety of static (shared) and instance methods on classes that implement IEnumerable and IComparable, such as the String, Enumerable, and Array classes. There are dozens of string comparison methods other than =,, , and Like, and none of them are affected by Option Compare. (The C# compiler doesn’t give you a choice.)Ĭontrary to what the name implies, this does not affect most string comparison methods available to you in VB.NET. So if you install Visual Studio and don’t change anything, your string comparisons are going to act just like they do in C# in all cases. In all versions of VB.NET, the default is Binary. The two options are Binary (the way C# does it) and Text. Option Compare is a two-option switch that determines how the CLR compares string data in comparison operations that use the =,, , and Like operators. In this post, I will discuss the Option Compare switch. You view and set compiler options in the Compile tab of the project properties sheet ( Figure A). Read the previous installments: Setting Visual Studio Compiler options, part 1 and Visual Studio compiler options, Part 2: Option Strict.Ĭompiler options are project-level settings that determine how the compiler behaves when it compiles your code. This is the third installment in my series on setting compiler options for Visual Studio VB.NET projects, versions 2005-2010. Here's what SMBs need to know about the option. Option Compare is a compiler option in VB.NET with the right default for all new projects. Visual Studio compiler options, part 3: Option Compare
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |