I had planned to write a piece about using yield return in c# to allow returning IEnumerable collections in a lazy way, however upon starting up Visual Studio in the news I discovered Bill Wagner’s piece on MSDN entitled ‘Custom Iterators‘ which covers everything I was planning to write about.
This ordering was pretty much how I expected it to be, but the article has fully example code and some figures to back up the performance difference.
CLS, or the Common Language Specification is a set of rules which make up the most basic features of all .NET languages. Many .NET languages exceed these basic requirements and allow for features above and beyond the basics. For instance, C# allows for case sensitive public members, meaning that object.Property is different to object.property.
When developing .NET libraries for use by other developers it is a very good idea to have your library work in a CLS Compliant way, so that you are enabling all .NET languages to leverage your library. It also proves to be a good idea as many of the CLS Rules reflect good design practices.
This attribute tells the C# compiler to check the public aspects of whole assembly against the CLS Specification and will report any breaches of these rules as compile errors.
CLS Compliance may seem like an extra complication to development, but it really is a good idea as it forces you to consider the needs of other developers (in other languages) and does enforce a number of good practices via compile time checks.