What is CLS Compliant in c#?
when i watch the video about .Net Cross Language interoperability i came across CLS Compliant can any one explain about that
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sudeep Chourasia192 reputationPosted Sep 29, 2016, 5:55 AM EDT
CLS stands for the Common Language Specification. It's the minimal set of rules and required language features that a .NET language must implement and understand. This set is a subset of the common type system, which defines how types are defined in .NET.
Being CLS compliant means that you can write code that can be consumed by any language that can be compiled and run on the CLR. But CLS compliance is not required, giving you the flexibility in cases where CLS compliance would be hard or impossible to do.
If you intend your code to be consumed by other developers, your API (your public classes and methods) should be CLS compliant. You should declare this by adding the CLSCompliantAttribute to your assemblies. If you are not writing for others, CLS compliance is not necessary.
When your assembly is marked with the CLSCompliantAttribute, the compiler will (should!) check your code to see if, when compiled, it will violate any of the CLS rulesand report violations to you for fixing.
Rajeesh MenothRank #118 · 18.4K reputationPosted Sep 28, 2016, 9:09 PM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Sep 29, 2016, 6:17 AM EDT