C#: Nonzero-based arrays are not CLS-compliant


I am currently reading Albahari's C# 3.0 in a Nutshell and on pg. 241, whilst talking about Array indexing, he says this:

Nonzero-based arrays are not
CLS (Common Language Specification)-compliant

What does it mean exactly, for nonzero arrays to not be CLS compliant ? And what implications does it have on your code?


Here is a link to the page of the book.

Best Solution

The CLS (Common Language Specification) lays the groundwork for a common set of rules for compliance that guarantees that other languages (VB.NET, F#, etc.) can use assemblies that you have built with C#. A nonzero-based array would not be compliant as other languages expect arrays to be zero-based.

Here is an example that is easier to understand:

class Foo
    public void Bar() { }
    public void bar() { } 

This type would not be CLS compliant since it contains two members that differ in name only by type. How would someone using VB.NET disambiguate between Bar and bar since the VB.NET compiler is not case-sensitive?

So basically the CLS is a bunch of rules like this to guarantee interoperability between languages.