CLS Attribute in DotNet

No.of Views1333
Bookmarked0 times
Downloads 
Votes0
By  RRaveen   On  15 Feb 2010 22:02:46
Tag : CSharp , Miscellaneous
CLS Attribute in DotNet
emailbookmarkadd commentsprint

Images in this article missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at info@codegain.com

 

Hi Guys,
The when i see the microsoft forums and other forums sites, many guys ask about CLSCompliant attribute in the class file or assembly. i have idea about that , and i will post here. It's not complicated, but have some conditions and etc...

The conditions means, CLS-Command Language Specification(.NET).When i can say .net is great framework for all guys.because of it's multi language supporting such as VB.NET,C++.NET,C#.NET,J# and etc....Somebody can ask how can support a framework to multi language? answer is that is th .NET FRAMEWORK.

Come to point..
so when we try a code in any language with .net Framework, we must follow few rules , when we will apply CLSCompliant attribute.

a::The methods are not same. it;s we have one method call "GetUsers()", and we don't have a method like "GETUSERS()".

b::Only properties and methods may be overloaded, Operators should not be overloaded.

c::We must avoid unsignned datatype within the class file

d::Publicly exposed members cannot start with an underscore ( _ )

e::Unsafe types like pointers should not be used with public members. However they can be used with private members.

f::Operators can't be overloaded

g::Unsigned types should not be part of the public interface of the class.


we can apply CLSCompliant to assemblies, modules, types, and members.


{codecitation class="brush: c#; gutter: true;" width="500px"}

Example::A(apply to class)
[CLSCompliant(true)]
public class Smp
{

}


{/codecitation}

Example::B(apply to assembly

{codecitation class="brush: c#; gutter: true;" width="500px"}


using System;
[assembly:CLSCompliant(true)]


{/codecitation}

Con....

If you develop applications that conform to the CLS, your program will be interoperable with a wide range of .Net supported programming languages. Therefore, your application is likely to have a wider customer base than a non-CLS-compliant version of your application. You can make sure that the C# programs you develop are CLS compliant by using the CLSCompliantAttribute, which will cause the compiler to raise errors if the program is not CLS compliant.

 
Sign Up to vote for this article
 
About Author
 
RRaveen
Occupation-Software Engineer
Company-TGS
Member Type-Gold
Location-Singapore
Joined date-03 Jun 2009
Home Page-codegain.com
Blog Page-www.codegain.com
- B.Sc. degree in Computer Science. - 4+ years experience in Visual C#.net and VB.net - Obsessed in OOP style design and programming. - Designing and developing Network security tools. - Designing and developing a client/server application for sharing files among users in a way other than FTP protocol. - Designing and implementing GSM gateway applications and bulk messaging. - Windows Mobile and Symbian Programming - Having knowledge with ERP solutions
 
 
Other popularSectionarticles
Comments
There is no comments for this articles.
Leave a Reply
Title:
Display Name:
Email:
(not display in page for the security purphase)
Website:
Message:
Please refresh your screen using Ctrl+F5
If you can't read this number refresh your screen
Please input the anti-spam code that you can read in the image.
^ Scroll to Top