Teach Yourself Visual Studio® .NET 2003 in 21 Days [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Teach Yourself Visual Studio® .NET 2003 in 21 Days [Electronic resources] - نسخه متنی

Jason Beres

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید













Understanding the Common Language Specification


The CLS describes the concrete guidelines that make a .NET language compliant with the common language runtime. That doesn't mean a .NET language can't have language-specific features, but it does indicate that to be considered a .NET language, the language must comply with the set of requirements set forth in the CLS. All features added to a .NET language and that aren't part of the CLS won't be exposed to other .NET languages at runtime.

If your code is fully CLS compliant, it's guaranteed to interoperate with all other components written in any .NET language. Certain languages, such as C#, attempt to accommodate developers moving from C and C++ with the similarity of their syntaxes. Because C# attracts such developers, it includes functionality familiar from their native languages, such as pointers and code access to unsafe memory blocks. This functionality is not CLS compliant and won't be accessible by other .NET languages, but it's allowed by the common language runtime and the language-specific compilers. To make sure that your code is CLS compliant, compilers such as C# include checks for non-CLS-compliant code through the use of attributes. If you apply the CLSCompliantAttribute attribute to a class or method in your code and the code isn't CLS compliant, an error occurs and the compile fails. The following code demonstrates how to apply the CLSCompliantAttribute attribute in your code:


using System;
[assembly: CLSCompliantAttribute(true)]
[CLSCompliantAttribute(true)]
public class Class1
{
public void x(UInt32 x){}
public static void Main( )
{
}
}

In this case, the code won't compile because unsigned integers aren't part of the CLS.

The second part of the verification process that the JIT compiler goes through to make sure that your code executes correctly is the verification of types. All types used in .NET must conform to the CTS.



    / 270