Wednesday, January 23, 2008

Stomach Pain Dark Stool

The programming language C #. The preprocessor.

Author: José Antonio González Seco
 full course available in DOC and PDF formats the author's web 

.
  Preprocessing  
 
preprocessor Concept

  • preprocessing directives
  • preprocessor Concept
  • The preprocessed is a prerequisite the compilation by which you can control how it is made. The preprocessor auxiliary module is used by the compiler to perform these tasks, and finally the compiler compiles the result of applying the text file preprocessor source, a result that is also a text file. Note then, that while the compiler does a translation of text to binary, so the preprocessor does is a translation from text to text. Those who have experience in the use of preprocessor languages \u200b\u200blike C + + and know the problems involved in land use can breathe easy, because in C # you have eliminated most of the features of it that caused errors difficult to detect (macros , include directives, etc..) practically only used to allow for conditional compilation of code.
Continue Reading ...


Policy Concept. Syntax The preprocessor does not interpret in any way the source code file, but only interprets the file what are called preprocessor directives
character) For example: # define TEST There was a fatal error not worry now if understand the meaning of these directives, as will be explained later. All must know is that the name shown after the # symbol is the name of the policy, and the text that comes after him (not all policies necessarily have to include it) is the value that is given. Therefore, the syntax of a directive is: #
\u0026lt;nombreDirectiva>
\u0026lt;valorDirectiva>
may include comments on the same line when declaring a policy, but these can only be a line comments starting with
    / /
  • . For example, the comment is valid: # define TEST / / Has there been any errors during the preprocessing But this one does not, because although , a line has the syntax of the comments may span multiple lines:
      As already mentioned, the main usefulness of the preprocessor in C # is possible to determine which regions of code in a source file be compiled. To do this, what is done is to enclose optional sections of code within conditional compilation directives, so that only compiled if certain preprocessor identifiers are defined. To define a tag of this type of policy used follow this syntax: # define
    • \u0026lt;nombreIdentificador>
    • This directive defines a preprocessor identifier \u0026lt;nombreIdentificador>. Although further study in detail what are the valid names as identifiers in C #, for now we consider to be valid those formed by one or more alphanumeric characters such
    that are neither true nor

false and do not start with a number. For example, to define a preprocessor identifier would name TEST: TEST # define By convention, these identifiers are given names in all uppercase letters, as in the example above. Although it is only a convention and no requirement to use it, this is the nomenclature we will use in this document and is the one that follows Microsoft in its example code. Become familiar with it because there are a lot of code written that uses it and why use it easier for others to read your code as it is the notation we expect to find. is important to note that any definition of identifier must precede any use of code in the source file. For example, the following code is invalid because it before # define have included source code (the class A):
class A {} # define TEST
However, although there can be no code before a # define themselves that there is freedom to precede other preprocessor directives. there an alternative way to define a preprocessor identifier and also allows the definition only applies in a particular compilation. This form is to pass to the compiler in its call option
/ d: \u0026lt;nombreIdentificador>
(short for

/ define: \u0026lt;nombreIdentificador> ), in which case during compilation are considered to be the beginning of all source files compile the identifier is defined above. The following three types of call are equivalent and define compiler preprocessor identifiers name TEST and TRACE when compiling a source file name ejemplo.cs csc / d: TEST / d: TRACE ejemplo.cs csc / d: TEST , TRACE ejemplo.cs csc / d: TEST; TRACE ejemplo.cs Note in the example that if we want to define more than one identifier using this technique we have two alternatives: to include several options / d the call to the compiler or define various these identifiers in the same option
/ d
characters separated by comma (, ) or semicolon ( ; ) When working with Visual Studio.NET, rather than directly to the command line compiler, then you can get the same effect through
View
à
Property Pages
à Configuration Options

 
  à    Build 
à
 
 Conditional Compilation Constants 
, where he again used the semicolon (; ) or comma (, ) as separators, you can define multiple constants . For everything to work well, before selecting View
has
selected in the Solution Explorer
  (opens with  View 
à
 
Solution Explorer) project to apply the definition of the constants.

Finally, regarding the use of # define
 
only comment is that you can define the same policy several times without causing any error in the compiler, allowing us to pass as many values \u200b\u200bof the option / d compiler as you want without fear of conflict with IDs already included preprocessing the source to compile. Elimination

identifiers preprocessing
 the same way that you can define preprocessor identifiers, you can also delete the definitions of this type of identifiers previously made. To this end the policy that is used has the following syntax: # undef 
\u0026lt;nombreIdentificador> If you try to eliminate this policy an identifier that has not been defined or the definition of which has already been eliminated there will be no error, but simply the removal policy will be ignored. The following example shows an example of this in the second # undef is ignored: # define Version1 Version1 # undef # undef Version1 As was the case with # define directives

, you can not include source code before # undef directives but, at most, all that could be included before they would preprocessor directives. Conditional Compilation As has been repeated several times over the issue, the main use of preprocessor in C # is to allow the compilation of conditional code, which is only allowed to compile certain regions source if the defined preprocessor variables satisfy some given condition. To achieve this using the following set of directives: # if \u0026lt;condición1> \u0026lt;código1> # elif \u0026lt;condición2> \u0026lt;código2> ... # Else # endif \u0026lt;códigoElse> The meaning of a structure like this is that if you meet \u0026lt;condición1>> is then passed to the compiler \u0026lt;código1>, if this happens but meets \u0026lt;condición2> , then what would the compiler would \u0026lt;código2>, and so continuously until to reach a branch # elif whose condition is met. Failure to meet any but one branch # else will be passed to the compiler \u0026lt;códigoElse>, but if this industry did not exist then it would pass any code and continue preprocessing the following code to # endif in original source. Although the branches # else # eldif and are optional, we must be careful not to mix, as the branch # else can only appear as the last branch block # if ... # Endif . various structures can be nested # If ... # Endif , as the following code:

# define TEST using System; class A {public static void Main () {# if TEST Console.Write ("This is a test") # if TRACE Console. Write ("to draw") # elif! TRACE Console.Write ("no trace"), # endif # endif}} As shown in the example, the conditions are specified preprocessing identifier names, considering that each condition only true if the identifier that follows it is defined. Or what is the same: a better way preprocessing identifier ( true in C #) if defined and false (false in C #) or not.

symbol! included in next to the policy value # elif is the symbol for "no" logical and

# elif

  used in allowing us to indicate that if that is not defined TRACE ID preprocessed have to pass to the compiler instructions listed below (ie, the Console.Write ("no trace");  
The source code will the compiler preprocessor if you compile without specifying any / d the call to the compiler is:
 using System; 
class A {static void Main () {Console.Write ("This is a test") Console.Write ("no trace"); }} Note how the code passed to the compiler and do not see any preprocessor directives, the preprocessor because what happens is the code resulting from applying the original preprocessor directives it contained. Also, if compilásemos original source code by calling the compiler with / d: TRACE, what would the compiler preprocessor is: using System;
class A {public static void Main () {Console.Write ("This is a test") Console.Write ("no trace");}}
Until now we have seen that the condition of a # if or # elif identifier may be preprocessed, and worth it true or false depending on whether or not defined. Well, these are not the only type of valid conditions in C #, but it is also possible to include terms containing logical expressions formed by pre-processing identifiers, logical operators (
!
for "not",
 & &  for "and" and   TEST TRACE as are / / defined or if no one is. # If TRACE! = TEST / / only be met if TRACE is defined and TEST or not / / vice versa # if TRACE & & TEST / / only be met if defined TRACE and TEST. # If TRACE  special meaning they have in the conditions of  # if  and  # elif  
Generation of warnings and errors

Preprocessor C # also provides guidelines for generating warnings and errors during the process preprocessing should become interpreted by the preprocessor. These directives have the following syntax: # warning # error \u0026lt;mensajeAviso> \u0026lt;mensajeError> The directive # warning making process is caused when the compiler produces a warning message that follows the format standard used by him for that and descriptive text of which has the contents listed on \u0026lt;mensajeAviso>, and # error
does the same thing causing an error message instead of a warning.
Using conditional compilation directives can control when they have to produce these messages, when they have to process these directives. In fact the main use of these guidelines is to allow error control assigning values \u200b\u200bto different preprocessing identifier code and an example of this is: # warning not yet revised Code # define TEST # if TEST & & FINAL # error A code can not be simultaneously test and final version # endif class A {} This code will always produce the warning message, but the # if
 indicates that only produce error message if you have defined IDs simultaneously preprocessed TEST and FINAL. 

As can be seen from the example, the preprocessor of C # considers that messages related to directives
# warning or # error
are all text that is after the name of such directives and to the end of the line which they appear. Therefore, any comments to be included in a line of this type will be considered as part of message to be displayed, not as a comment as such. For example, before the board:
# Compilation failed error / / Error What will display a message as follows: Fichero.cs (3.5): error CS1029: The compilation has failed / / Error Changes line numbering
By default, the compiler lists each source file lines as the normal order in which they appear in it, and this order is the following information when errors or warnings during compilation. However, there are situations that are interested in changing these numbers, and it provides a policy with the following syntax: # line
\u0026lt;number>
 
"


\u0026lt;filename>
" 
This directive tells the preprocessor to be considered by the next line of the source file that appears is the line whose number is indicated, regardless of the value that the numbering had used at that time. The value shown on " \u0026lt;filename> " is optional and should appear indicating the name to be considered to have the file at a time to give error messages. A eg # line 127 "csmace.cs" This use of # line that the compiler has to consider the next line is line 127 of file csmace.cs. Since she will continue using the normal numbering system (the one after that will be the 128, csmace.cs, the next the 129, etc.) Unless later renumber again with another # line directive . Although in principle it may seem that this policy is of little use, the fact is that usually comes fairly well for writing compilers and other tools that generate code in C # from code written in other languages. Marked source regions
 
may mark regions of code and associate a name using the guidelines set # region # endregion and . These directives are used as follows: # region # endregion \u0026lt;nombreRegión> \u0026lt;code> income given to these markings depends on the tool, but at the time of writing the only tool that made use of them Visual Studio.NET was where it is used to mark code so that from the code window can expand and contract with a single mouse click. Specifically, the code window of Visual Studio you will see a symbol [-] next to the regions marked by code so that clicking on it all the code in the region will be compressed and replaced by the name given to \u0026lt; nombreRegión>. After this, the [-] will become a [+] and if we press the collapsed code will expand and regain its original appearance. Below is an example of each:

Figure 4: Region Code expanded

     
Figure 5: Region Code contracted

 Be careful when nesting areas with conditional compilation directives, since all block 
# if ... # Endif

beginning within a region has also finished inside. Therefore, the next use of the # region directive is not valid because it ends up being the block RegiónErrónea
 # if ... # endif open: 
# region RegiónErrónea # if A # endregion # endif
 
(C) 2001 José Antonio González Seco

  addthis_url = ''; addthis_title = ''; addthis_pub = 'igner';        

Monday, January 21, 2008

How To Upload Images Java

The programming language C #. Introduction to C #.

Author: José Antonio González Seco
Full course available DOC and PDF formats on the author's web .
 
INTRODUCCIÓNAC #

Origin and need a new language

Features C #

Writing applications
 

clip_image002

Origin and need a new language


C # (read in English "C Sharp" and in English "C Hash") is the new general-purpose language designed by Microsoft for. NET platform. Its main artists are Scott Wiltamuth and Anders Hejlsberg, the latter also known for being the designer of the Turbo Pascal language and Delphi RAD tool. clip_image002[4] Although you can write code for the platform. NET in many other languages, C # is the only one that has been designed specifically for use in it, so to program it using C # is much easier and intuitive to do with any of the other languages \u200b\u200bas C # does not have unnecessary elements inherited. NET. For this reason, they say that C # is the native language . NET

The syntax and structure of C # is very similar to C + + or Java, since the intention n of Microsoft to facilitate migration codes written in these languages \u200b\u200bto C # and facilitate their learning to developers accustomed to them. However, its simplicity and high productivity are comparable with those of Visual Basic. A language that would have been ideal to use for these purposes is Java, but due to problems with the company that created the self-Sun-Microsoft has had to develop a new language to add to the proven virtues of Java the modifications that Microsoft was planning to add to improve it even Masy oriented language component development.


In short, C # is a programming language that takes the best features of existing languages \u200b\u200bsuch as Visual Basic, Java or C + + and combines them into one. Being relatively new does not mean it is immature, as Microsoft has written most of the BCL using it, so that your compiler is the most refined and optimized from those included in the . NET Framework SDK Continue Reading ...
 

Features C #


With the idea that more experienced programmers can get an overview of the language, following is a summarized the main features of C # Some of the features identified here are not exactly own the language but of the platform. NET in general and if it is discussed here because they have a direct impact on the language:
The code written in C # is

The size of the basic data types is fixed and independent of the compiler, operating system or machine for those compile (not as in C + +), which facilitates code portability.

    not include items of little use in languages \u200b\u200bsuch as C + + such as macros, multiple inheritance, or need a different operator from the point (
  • . ) members access spaces names (:: Currency:
      C # language incorporated the elements over the years has been proving very useful for application development and in other languages as Java or C + + is to simulate, as a basic type decimal
    • that allows high-precision operations with real 128-bit (very useful in the financial world) the inclusion of a foreach statement
  • para representar cadenas o la distinción de un tipo

bool específico para representar valores lógicos.
Orientación a objetos:
Como todo lenguaje de programación de propósito  general  actual, C# es un lenguaje orientado a objetos, aunque eso es más bien una característica del CTS que de C#. Una diferencia de este enfoque orientado a objetos respecto al de otros lenguajes como C++ es que el de C# es más puro en tanto that do not support or functions or global variables, but all code and data must be defined within the definitions of data types, which reduces problems with name conflicts and facilitates the readability of the code. C # supports all the features of the paradigm of object-oriented programming: encapsulation

, inheritance and polymorphism

.

Regarding encapsulation is important to note that apart from the typical modifiers

public, private

and protected
, C # adds a fourth internal switch called
, which can be combined with protected
and indicates that the element to the definition above Só can be accessed from the same assembly.

respect to inheritance, unlike C + + and Java-like C # only supports single inheritance of classes and that the multiple causes more headaches that facilities and the most cases their use can easily be simulated by multiple inheritance of interfaces. Anyway, This is again rather a characteristic of CTS than C #.
    other hand and unlike Java, C # was chosen to make all the methods are by default sealed and redefines are to marked with the modifier virtual
  • (as in C + +), thus avoiding errors due to accidental overrides. In addition, a side effect of this is that calls to be more efficient methods to not be default to search in the virtual function table implementation thereof which shall be called. Another side effect is that it allows calls to virtual methods can be made more efficiently to contribute to this table size is reduced.
    • component orientation: The very syntax of C # include elements of the design of components that other languages \u200b\u200bhave to be simulated by maso less complex constructions. That is, the syntax of C # allows you to define properties comfortably
    (similar to controlled access areas)
    events (controlled association response functions notifications) or
    • attributes (information about a type or its members)
    • automatically Management Memory policy: As mentioned, any language. NET has at its disposal the CLR garbage collector. This has the effect that language is not necessary to include instructions for destruction of objects. However, since the destruction of objects through the garbage collector is undetermined and it is only done when is active, whether through lack of memory, application termination explicit request in the source-, C # also provides a mechanism for liberation No deterministic resources through instruction using
    .
  • Type safety: C # include mechanisms to ensure that access to data types are always running smoothly, allowing you to prevent errors difficult to detect memory access belongs to any object and is especially necessary in a managed environment by a garbage collector. This will take measures such as: only supported conversions between compatible types . That is, between a guy and his predecessors, including types for which they have defined explicit conversion operator, and between a guy and his son type of an object of the first stores a reference the second ( downcasting ) Obviously, the latter can only see it in the CLR runtime and not the compiler, so that in fact the compiler and CLR work together to ensure correction conversions.
can not use uninitialized variables
  • . The compiler gives the fields a default consisting of them to zero and controlled by control flow analysis of source not read any local variable without being previously assigned any value.

    be seen that all access to elements of a table is made indices that are within range of it.

    can control the production overflow in arithmetic operations, informing it with an exception when it occurs. However, to achieve a better performance in arithmetic these checks are not done by default to operate but only with continuous variables (can be detected at compile time) Unlike Java, C # includes delegates , which are similar to function pointers in C + + but still an object-oriented approach, can store references to several methods simultaneously neously, and checked The methods that aim to have parameters and return value to define the type indicated. can define methods that support an indefinite number of parameters of a certain type, unlike languages \u200b\u200blike C / C + +, C # always checked that the values they spend on each call rates are appropriate.


    safe
    Instructions: To avoid common errors in C # you have imposed certain restrictions on the use of common control instructions. For example, the guard of any condition must be a conditional expression, not arithmetic, thus avoiding errors due to confusion of the equality operator (==
  • ) with the assignment (
    =
  • ) and any case of a switch must end in a break or goto
    indicating what the following conduct, which prevents accidental execution of cases and makes necessary changes.
  • unified type system: Unlike C + +, C # all data types derive always defined, even implicitly, of a common base class called System.Object
    , so you will have all the members defined in this class (ie, are "objects")
  • Unlike Java, C # this also & # 233, n applies to basic data types. In addition, to ensure that this does not impact negatively on their performance level, we have included a transparent mechanism for boxing
  • and unboxing
    • with which ensures that only treated as objects when the situation demands, and meanwhile, qualify for specific optimizations ficas. The fact that all types of language derived from a common class greatly facilitates the design of generic libraries that can store objects of any kind.
Extensibility basic types:
    C # to define, through
    • structures, data types for which apply the same optimizations as for basic data types. That is, they can be stored directly on the stack (after its creation, access will be faster destruccióny) and assigned a value and not by reference . To ensure that the latter does not have negative effects when passing structures as parameters of methods, there is the possibility of passing references to stack through the switch parameters ; meters
    ref.
    • Extensibility operators: To facilitate the readability of the code and ensuring that the new basic data types defined by the structures are the same basic level as predefined in the language, like C + + and Unlike Java, C # allows you to redefine the meaning of most operators, including conversion, both implicit and explicit conversions, as they apply to different types objects.
    operator redefinitions are made wisely, so that from a single definition of operators + +
    • and -
    the compiler can automatically deduce run on a prefix and postifja, and defining simple operators (eg +
    • ), the compiler figures out how to apply their version & # 243, n compound assignment (+ =) Also, to ensure consistency, the compiler checks that the operators always redefine opposite pairs (for example, if you redefine ==
    , we must also redefine
    ! =
    • )
    also given the opportunity, through the concept of
    indexer, to redefine the meaning
  • operator [] for data types defined by the user, which ensures that you can access it like a table. This is very useful for working with types that act as collections of objects. Extensibility switches: C # offers, through the concept of attributes , the ability to add metadata resulting from the compilation module No additional information from any source that generated by the compiler which can then be accessed at runtime through the reflection library. NET. This, rather is a characteristic of the platform. NET and not C #, can be used as a mechanism for defining new switches. Version: C # includes versioning policy for creating new versions of rates without fear that the introduction of new members cause difficult to detect errors types and children previously developed and extended to members of the same name to new introduced. If a class introduces a new method which overrides the rule should continue to call the version of his father at some point in your code difficult easily follow this rule members of the same symbol defined in child classes prior to the definition thereof in the parent class, or if you enter a new field with the same name as algú n method of a class child, the child class will stop working. To avoid this in C # we take two steps:
  • It requires that any redefinition must include the override modifier , which version of the child class would never be considered as a redefinition version of the membership in the parent class because it does not include

    override. To prevent a programmer accidentally include this switch, only allowed to include members that have the same signature as marked as redefining members by using the virtual . That also avoids the error so common in Java to be believed have redefined a member, because if the override member not exist in the parent class will be a compilation error.

  • redefinition If not considered, then it is considered that what you want is to hide the parent class method, so that the child class is as if it never existed . The compiler will warn you of this decision through a warning message can be deleted including the new switch in the definition of member in child class so explicitly indicate the intent to conceal.
Efficient:
    In principle, in C # all the code includes many restrictions to ensure their safety and not allow the use of pointers. However, unlike Java, C # is possible to bypass these restrictions by manipulating objects through pointers. It is sufficient to mark regions of code as unsafe (modifier unsafe

  • ) and these pointers can be used in a similar way to how it is done in C + +, which can be vital for situations where needed efficiency and processing speed very large.
    Compatible: to facilitate the migration of programmers, C #, not only has a syntax similar to C, C + + or Java that allows to include directly in written in C # code snippets written in these languages, but the CLR also offers, through the so-called Platform Invocation Services (PInvoke ) The ability to access native code written as non-oriented single functions such as object DLLs of the Win32 API. Note that the ability to use pointers in unsafe code permits you to easily access these functions, as they often expect to receive or return pointers. can also be accessed from code written in C # to COM objects. To facilitate this, the . NET Framework SDK includes a tool called tlbimp and
    regasm
    by which it is possible to automatically generate proxy classes that allow, respectively, using objects COM from. NET as if objects. NET objects shall be registered. NET for use from COM.
  • Finally, there is also the possibility of using ActiveX controls from code. NET and vice versa. For the first utility is used
    aximp
  • , while the latter is used for the aforementioned regasm
  • .
  • applications
    Writing
      Basic application Hello World!
    • Basically an application in C # can be viewed as a set one or more source files with instructions for the application to work as intended and are passed to the compiler to generate an executable. Each of these files is just a plain text file written using Unicode characters and following the proper syntax C #. As a first contact with the language, nothing better than a typical induction program "Hello World!" The only thing that makes run is to show on screen the message Hello World! Your code is: 1: class HelloWorld 2: {3: static void Main () 4: {5: & # 160; System.Console.WriteLine ("Hello World!") 6: & # 160;} 7:} All code written in C # was to write within a class definition, and that the l & # 237; line 1: is said to be defining a class (class ) called HolaMundo1 whose definition will be between the opening brace line 2: and its corresponding closing brace on line 7 line :
    • Within the class definition (line
    3:
) defines a method whose code name Main is the right choice among the key
    opening line 4:
      and their respective closing brace (line
    • 6: ) A method is simply a set of instructions to which are associated with a name, so enough to run later referenced by its name instead of having to rewrite them. The particle that precedes the method name indicates which type of value returned after executing the method, and in this case
    • is void
means that nothing is returned. For their part, placed in parentheses after the method name indicates what parameters it takes, and they are empty & # 237; I mean that the method does not take any. The parameters of a method can change the outcome of its execution based on values \u200b\u200bthat are given in each call.
  • The word static preceding the declaration of the return type is a modifier the meaning of the statement indicating that the method method is associated with the class within which is defined and not the objects created from it. Main () is called the entry point application, which is simply the method by which start execution. Need
static modifier to prevent
  • to call has to create an object of the class where defined. Finally, line 5: contains the instruction code to execute, that what is done is to request the implementation of m & # 233; all WriteLine ()

    class Console defined in the namespace System passing as a parameter string with the contents , Hi World! Note that text strings are sequences of characters delimited by double quotes even if those quotes are not part of the chain. For its part, a namespace may be considered for the classes is similar to what a directory is for files: a way to group them. WriteLine Method () be used very often in the coming issues, so it should be noted now that a way to call that used repeatedly is to pass an indefinite number of other parameters of any type and include in the first substring of the form {i}

    . This is done to display the console window the string passed as first parameter but replacing the substrings {i} the value converted to string torque & # 225; meters occupying the i +2 position in the call to WriteLine ()
. For example, the following 5 years I have
show the screen if x were worth 5: System.Console.WriteLine ("I have {0} YEAR I " x); To indicate how to turn every object into a string simply redefine the method ToString ()
, although this is something that will not show until the
Item 5: Classes . Before going is important to note that C # is case sensitive, which means that capitalization does not like to be written with identifiers. That is, is not the same type that it supports or CONSOLE Console, and if it is one of the two forms the compiler will fail because in the namespace System


there is no class with those names. In this regard, we note that a common mistake among Java programmers are accustomed to calling the main entry point instead of Main, which causes a runtime error while compiling the compiler does not detect & # 225; no definition of entry point.
 
entry points It has been said that the entry point an application is a method named Main that will contain the c & # 243; say where it has to start running it. So far only has been a version of
Main ()
that takes no parameters and return type is void , but in fact all possible versions are:

static void Main () static int Main () static int Main (string [] args
)
static void Main (string [] args ) As shown, there are versions of Main () that return a value of type int . A int is just a data type capable of storing integer between 1

2147 483,648 and 2,147 1 483,647, and the number returned by Main () would be interpreted as return code of the application. This value is often used to indicate whether the application successfully completed (usually value 0) or not (value as the cause of abnormal termination) and Item 8: Methods will explain how to return values. There are also versions of Main () that take a parameter to contain the list of arguments that the application was called, so it is only useful to use these versions of the entry point if the application will use These arguments for something. The type of this parameter is

string [] , which means it is a text string table (in the Item 5: Classes will explain in detail what are the tables and chains), and its name-which is to be used within the code in Main () to make reference, is args in the example, although it could gives ; rsel anyone else. Compilation command line After writing the above code with any text editor, like Notepad Windows-and stored in plain text in a file HolaMundo.cs to compile simply open a console window (MS-DOS in Windows), placed in the directory where you are and have fun as a couple & # 225; subway and compiler: csc HolaMundo.cs
 
csc.exe is the C # compiler included in the. NET Framework SDK for Microsoft Windows. Although in principle the SDK installation program automatically adds the path to seamless call from any directory if you installed via VS.NET does not occur and must be set either manually or by running the batch file Common7 \\ Tools \\ vsvars32.bat that VS.NET includes under its installation directory n, or opening the console window from the icon to Visual Studio.NET

à Command Prompt Visual Studio.NET for the group VS.NET programs in the Windows Start menu does nothing but open the console and automatically call vsvars32.bat

. In any case, if you use other compilers of C # can be varied as to make the compilation, so that what is explained here in principle only be & # 225; valid for C # compilers for Microsoft Windows. After compilation would get an executable named HolaMundo.exe whose execution produces output in the console window:
Hello World!
If the application you are going to build does not use the console window to display the output but a graphical interface screens, then it would have to compile it from the compiler option / t with the value winexe before the name of the file to compile. If not they would do so would open the console window each time you run the application window, which is usually undesirable in these applications. So, to compile a windows executable Ventanas.cs would convenient to write: csc / t: winexe Ventanas.cs

Note that although the name
 winexe  give the impression that this value for the option 
/ t
only allows to generate executables windows, in fact it is permitted to generate executables with no associated console window. Therefore also be used to generate executables that do not have any associated interface or console or graphical.
If instead of an executable, either console or windows, you want to get a library, then to compile the compiler must pass
option / t with the value
library> . For example, following the initial sample would have to write:
csc / t: library HolaMundo.cs In this case, create a file HolaMundo.dll which types of data you can & # 237, n used from other sources from the compiler a reference to them by selecting / r . For example, to compile a source executable A.cs HelloWorld class that uses the library HolaMundo.dll be written: csc / r: HolaMundo.dll A.cs Overall / r allowed to reference types defined in any assembly, so the value you provide also may be the name of an executable. In addition, each build may reference multiple assemblies including self either option / r once every one or multiple references including self in a only option / r
using commas or semicolons as separators. For example, the following three calls to the compiler are equivalent:
csc / r: HolaMundo.dll; Otro.dll; OtroMás.exe A.cs csc / R: HolaMundo.dll, Otro.dll, OtroMás.exe A.cs csc / t: HolaMundo.dll / r: Otro.dll / r: OtroMás.exe A.cs It should be noted that although not indicated anything in any compilation always default reference to the library mscorlib.dll of the BCL, which includes the types of use m & # 225; s common. If you use BCL types not included in it should be included when compiling references to libraries where they are defined (in the SDK documentation on each type of BCL can find information about where it was defined) Both executables and libraries are assembled. To generate a code module that is not part of any assembly, but contains definitions of types that may be added to assemblies that are compiled later, the value to be given the option to compile / t
is
module. For example: csc / t: module HolaMundo.cs

With the above statement would create a module called HolaMundo.netmodule could be added to compilations assembled by including as the value of the option / addmodule
. For example, to add the module before compiling the source library and bookstore Lib.cs wrote:    csc / t: library / addmodule: HolaMundo.netmodule Lib.cs  
though so far all such compilations have been made using a single source file, nothing really prevents that can be used more. For example, to compile and B.cs A.cs files in a library A.dll be implemented: csc / t: library A.cs B.cs Note that the default name given to the executable is always equal to the first source with the extension specified own the type of compilation made (. exe for executables, . dll for bookstores and . netmodule module) However, you can specify & # 160, as the option value / out any other compiler
as the following example to compile the file A.cs> as a library name Lib.exe:
  csc / t: library / out: Lib.exe A.cs    Note that although it has been given a name ending in 
. Exe the resulting file, it remains a bookstore & # 237; to and not try to run an executable and produce an error message. Obviously it makes little sense to give that extension, and only been given in this example to show that, though recommended, the file extension does not necessarily correspond really the file type of question. When specifying files to compile can also use wildcard characters Typical operating system. For example, to compile all files with extension. cs current directory in a library called Varios.dll would:
  csc / t: library / out: *. cs   varios.dll  With what needs to be careful, especially when compiling a number of sources is not compiled with both more a data type with entry point, because then the compiler does not know which one to use as the beginning of the application. To target can be specified as the value of the option 
/ main name type that contains Main () has been used as entry point. So, to compile and B.cs A.cs files into an executable which is the entry point type defined in the Principal, should write: csc / main: Main A.cs
B.cs
course, for this to work or B.cs A.cs must contain a definition of some guy named Principal with a single m & # 233; all valid as an entry point (obviously, if it contains several volveríaa have the problem of not knowing which one to use)
 Compilation Visual Studio.NET     To compile a Visual Studio.NET application must first be included within any project. To do this simply press the button New Project 
on the home page is showing only start this tool, after which he will get a screen with the look shown in Figure 1
.   In the box labeled window shown  Project Types  has to select the type of project to create. Obviously, if you go to work in C # the option should be choice will always be in the same Visual C # Projects. 
Box Templates has to select the template for the project within subtype of the type in Project Types to be done. To make a console executable, as in our case, we must select the icon labeled Console Application. If you wanted to make a library would have to select Class Library> and if Kishi make a windows executable would have to select Windows Application. Note that we make no template for modules, which is that from Visual Studio.NET can not be created.
 Finally, in the Name text box   has to write the name to give to the project and  Location  the base directory associated with it. Note that low 
Location a message informs you about which is the directory where files are stored finally the project, which will be the result of concatenating the path specified for the base directory and the name of the project.

Figure 1: Window to create new project in Visual Studio.NET
 Once set all these options, pressing OK button   Visual Studio will create the entire infrastructure to begin to work comfortably in the project. As shown in Figure 2  , this infrastructure consists of the generation of a source that will serve as a template for projects of that type ( in our case, console applications in C #): 
   Figure 2: Template for console applications generated by Visual Studio.NET   From this template, write the code for the sample application is so easy to just type 
 System.Console.WriteLine ("Hello World!" ;)   within the definition of   method Main () 
created by Visual Studio.NET. Of course, another possibility is to delete the entire workforce and replace the HelloWorld code shown above. Sea do as you do, to compile and run the application after that just press CTRL + F5 or select Debug à
 Start Without Debugging   in the main menu of Visual Studio.NET. To only compile the project, then you should select Build   à 
Rebuild All . However, in both cases, the executable is stored in the subdirectory Bin \\ Debug directory
project.
 the far right of the main window of Visual Studio.NET can find the Solution Explorer called   (if not available, select View  à  
Solution Explorer
), which is a tool that can find the necessary files that make up the project. If you select it the icon for the project you're working on and click View  à   Property Pages  get a property sheet for the project with the appearance shown in Ilustració 
n 3
:

Figure 3: Property Sheet in Visual Studio.NET project
This window allows visually configure most options that you call & # 225; the compiler command line. For example, to change the output file name (optional / out ) indicates the new name in the text box
Common Properties à General
à
Assembly Name to change the type of project to generate (option
/ t ) is used Common Properties à General
à
Output Type (as you will if you try to change it, you can not generate modules from Visual Studio.NET), and the type that contains the entry point to use (option / main ) is indicated in Common Properties à General

à Startup Object clip_image002

Finally, to add the project references to external assemblies (option

/ r

)
simply select Project à Add Reference from the main menu of VS.NET.

clip_image004 (C) 2001 José Antonio González Seco


addthis_url = ''; addthis_title = ''; addthis_pub = 'igner';

Tuesday, January 15, 2008

Best White Nfl Players

The programming language C #. Introduction to Microsoft.NET.

Author: José Antonio González Seco full course available in DOC and PDF formats on the author's web

. INTRODUCTION TO MICROSOFT.NET

Microsoft.NET Common Language Runtime (CLR) clip_image006

Microsoft Intermediate Language (MSIL)


Metadata Assemblies Base Class Library (BCL) Common Type System (CTS) Common Language Specification (CLS)

Microsoft.NET
Microsoft.NET is a set of new technologies that Microsoft has been working in recent years in order to get a platform simple and powerful way to distribute the software as services that can be provided remotely and can communicate with each other and combine completely independent of platform, programming language and model of components that have been developed. This is called
. NET platform

, as previously mentioned services are called Web services .


To create applications for the platform. NET, Web services and applications, both traditional (console applications, Windows applications, Windows NT services, etc..) Microsoft has released the so-called software development kit called
. NET Framework SDK, which includes the necessary tools for development and for distribution and implementation, and Visual Studio.NET
Microsoft.NET
Continue Reading ...
Common Language Runtime (CLR)

The
Common Language Runtime (CLR
) is the core. NET platform. Motor is responsible for managing the execution of applications developed for it and offering numerous services that simplify their development and promote their safety and security. The main features and services offered by the CLR are:
    • consistent programming model:
      All services and facilities offered by the CLR is accessed in the same way: through a model of object-oriented programming. This is a major difference on how to access services offered by some current operating systems (for example, family Windows), in which some services are accessed through calls to global functions defined in and other DLLs by objects (COM objects in the case of the Windows family)

    • simple programming model:
    • With the CLR away many complexities included in current operating systems (Windows registry, GUIDs, HRESULTS, IUnknown, etc..) The CLR is not that abstracts the programmer from these concepts, but are concepts that do not exist. NET platform
    • Elimination of the "hell of the DLL" on the platform. NET removes the problem known as "hell of the DLL" given current operating systems of Windows family, problem is that by replacing older versions of DLLs can be shared by new versions that applications that were designed to be run using the old stop working if the news is not 100% compatible with above. On the platform. NET newer versions of the DLLs can coexist with the old, so that applications designed to run using the old may continue using them after installing the new. This obviously greatly simplifies the installation and uninstallation of software. Implementation
    • platform: The CLR acts as a virtual machine, taking care to run applications designed for. NET platform. That is, any platform for which there is a version of the CLR can run any. NET application. Microsoft has developed versions of the CLR for most versions of Windows: Windows 95, Windows 98, Windows ME, Windows NT 4.0, Windows 2000, Windows XP and Windows CE (which can be used on CPUs other than x86 family ) On the other hand Microsoft has signed an agreement with Corel to port the CLR to Linux and there are others which are independently developed freeware versions of the CLR for Linux. Also, because the architecture of the CLR is completely open, it is possible that in future design versions of the same for other operating systems.
    • Integration Language:
      from any language for which there is a compiler that generates code for the platform. NET generated code can be used for the same using any other language as if the first code written using it were . Microsoft has developed a C # compiler generates such code, as well as versions of its compilers for Visual Basic (Visual Basic.NET) and C + + (C + + with extensions managed) that also generate and a version of the JScript interpreter (JScript . NET) that can interpret it. Language integration is such that it is possible to write a C # class that inherits from one written in Visual Basic.NET that, in turn, inherit from one written in C + + with managed extensions.

    • Memory management:
    • The CLR includes a garbage collector which prevents the developer to consider when to destroy the objects that no longer be useful. This collection is an application that is activated when you create a new object is detected that there is free memory to do so, if the collector runs in dynamic memory associated with the application, which detects objects in it that can not be accessed by the application code, and removed to clear the memory of "objects rubbish "and allow the creation of new ones. Thanks to this collection avoids common programming errors such as attempts to erase and deleted objects, memory exhaustion by forgetting or elimination of useless objects to access request object members and destroyed.
    • Type safety:
    • The CLR facilitates the detection of programming errors difficult to track by checking that all type conversion is performed during the execution of an application. NET is made so that the source and destination types are compatible .


Process Isolation: The CLR ensures that from code belonging to a particular process can not access code or data belonging to another, avoiding programming errors very frequent and prevents some processes to attack others. This is achieved thanks to the previously discussed type safety, it prevents an object can be converted at a rate larger than his own, and that when treated as an object of larger size could be accessed in memory space outside it could belong to another process. Also be achieved by having not allowed to access arbitrary memory locations. Exception handling: The CLR any errors that may occur during the execution of an application spread the same way: using exceptions. This is very different from what was being done on Windows systems to the emergence of the platform. NET, in which certain errors are transmitted using error codes in Win32 format, others by HRESULTS and other means of derogations.


The CLR allows code exceptions thrown. NET written in a certain language can be captured using code written in another language, including debugging mechanisms that can jump from code written for. NET in a particular language code written in any other. For example, you can traverse the call stack of an exception but it includes other methods defined in modules using other languages. Support multithreading : The CLR is able to work with applications that span multiple threads of execution that may evolve separately in parallel or interleaved, depending on the number of processors on the machine on which to run. Applications can launch new threads, destroy, suspend them for a while or until they get a notice, send notifications, syncing, etc.

transparent Distribution: The CLR provides the infrastructure to create remote objects and access them in a completely transparent to its actual location, as if they were in the machine that uses them.

Advanced Security:
The CLR provides mechanisms to restrict the execution of certain codes or permits assigned to them according to their procedendecia or the user that run. That is, can not afford the same level of confidence from the Internet code that code installed locally or from a local network may not be the same permissions to code from a particular manufacturer that other code, and can not given the same permissions to the same codes as the user who is running or as the role it plays. This allows a system administrator code that is running can not jeopardize the integrity of files, the Windows registry, etc.

interoperability with old code:
The CLR includes the necessary mechanisms to access from code written for the platform. NET code written before the appearance of it and therefore not ready to be executed within it. These mechanisms allow both access to COM objects such as access to pre-existing DLLs loose functions (such as Win32 API)
As can be deduced from the mentioned characteristics, the CLR it does is manage the implementation of applications designed for . NET platform. For this reason, the code of these applications is often called managed
code and the unwritten code to be executed directly on the platform. NET is often referred unmanaged code.

Microsoft Intermediate Language (MSIL)

  • None of the compilers that generate code for the platform. NET produces machine code for x86 CPUs or for any other specific CPU, but also generate code written in intermediate language called Microsoft Intermediate Language (MSIL

    ) The CLR gives applications the feeling that they are running on a virtual machine, and just MSIL is the machine code of the virtual machine. That is, MSIL is the only code that is able to interpret the CLR, and therefore when we say that a compiler generates code for the platform. NET what is being said is that it generates MSIL.
  • MSIL has been created by Microsoft after consultation with numerous experts in the writing of compilers and languages \u200b\u200bof both the academic and business world. It is a language of a level of abstraction much higher than most CPU machine codes exist, and includes instructions for working directly with objects (create, destroy, initialize, call virtual methods, etc.), tables, and exceptions (throw, catch them and treat them)
    already said that the C # compiler compiles directly to the source code to MSIL, Microsoft has developed new versions of their languages Visual Basic (Visual Basic.NET) and C + + (C + + with managed extensions), whose compilers generate MSIL, and has developed a JScript interpreter (JScript.NET) that generates MSIL code. Well, there are also numerous third parties who have announced to be made for the platform versions. NET languages \u200b\u200bsuch as APL, CAML, Cobol, Eiffel, Fortran, Haskell, Java (J #), Mercury, ML, Mondrian, Oberon, Oz, Pascal, Perl, Python, RPG, Scheme and Smalltalk.
  • The main advantage of MSIL is that it facilitates the implementation platform and language integration to be independent of the CPU and provide a common format for the machine code generated by all compilers that generate code for. NET. However, since the CPUs can not run directly MSIL, before running to be converted to native code of the CPU on which they take place. This is accomplished by a component known as the CLR JIT compiler (Just-In-Time) or jitter that is dynamically converting MSIL to native code to execute as needed. This jitter is divided into three versions

  • normal jitter: which is often used by default, and only compiles the MSIL code to native code as it is still necessary because it saves time and memory to avoid unnecessarily having to compile code never run. To achieve this, the CLR class loader initially replaces method calls of new classes to be charged for calls to functions (stubs) to be responsible for compiling the actual method code. Once compiled, the call to the stub is replaced by a direct call to the compiled code, so that subsequent calls to it do not need compilation.

  • economic jitter: works similarly to normal jitter just did not perform any optimization of code to compile, but that translates each instruction MSIL by equivalent machine code on the run. It is specially designed for use in embedded devices that have low power CPU and little memory, for even more inefficient code generated is less time and memory required to compile. Moreover, to save memory this jitter can be downloaded and compiled code that takes some time without running back and replaced by the appropriate stub. For these reasons, this is the jitter used by default in Windows CE operating system is usually included in the above embedded devices.
    Another use of economic jitter is that it facilitates the adaptation of the platform. NET to new systems because it is much easier to implement than normal. In this way, because it is possible to quickly develop a version of the CLR-managed applications that can run even from a less efficient, and once developed it is possible to focus on developing the normal jitter to optimize their execution.
  • prejitter: is distributed as a command line application called

    ngen.exe
  • by which to compile complete any executable or library (any general assembly, although this concept is discussed below) that contains managed code and convert it to native code, so that subsequent executions of the same will be using this version already compiled and does not waste time making dynamic compilation. The jitter performance for the execution of a managed application can give the feeling of making it run slower because you have to invest time in dynamic compilation. This is true, but be aware that it is a much more efficient than that used in other platforms such as Java, as in. NET each code is not interpreted each time it runs but only compiled the first time you call the method to which it belongs. Moreover, the fact that the compilation is done dynamically allows the jitter has access to much more information about the machine that will run the application would have any traditional compilers, which can optimize the code it generated (for example, using special instructions from the Pentium III machine if they are supported, using extra registers, including inline code
    , etc.) Furthermore, as the garbage collector. NET keeps dynamic memory compacted memory reserves will be faster, especially in applications that do not cover the memory and therefore do not require a garbage collection. For these reasons, engineers at Microsoft think that future versions of their jitters may even get managed code to run faster than unmanaged.


  • Metadata

    on the platform. NET are two types of
  • compiled code modules: executable (extension
  • .
exe) and dynamic link libraries
  • ( extension. dll generally) are files containing both data type definitions, and the difference between them is that only the former have a special method that serves as entry point from which to execute the code contained on a call from the command line operating system. Both types of modules are often referred

    portable executable (PE), because your code can run on any operating systems Windows family for which there is some version of CLR.
  • The contents of a module is not only MSIL, it also has two other important areas: the CLR header and metadata: The header

    CLR is a small block of information that indicates that it is managed and indicates a module is the CLR version you need, what is your digital signature, what is your point of entry (if an executable, etc.).
  • The
metadata are a set of data organized in tables that store information about the types defined in the module, their members and which are external to the module types that are referenced in the module . The metadata of each module is automatically generated by the compiler to create, and its tables include:
Table


Description




ModuleDef



    Define the characteristics of the module. It consists of a single element that stores a version identifier module (GUID created by the compiler) and the file name given to the module to compile (and this name is always available, even rename the file)


  • TypeDef

Define the characteristics of the types defined in the module. Each type is stored your name, kind father, their access modifiers and references to items in the tables of members for its members.
  • MethodDef
Define the characteristics of the methods defined in the module. For each method keeps its name, symbol (for each parameter is a reference to the appropriate item in the table ParamDef), switches and position of the module which starts the MSIL of your body.


ParamDef

Define the characteristics of the parameters defined in the module. Of each parameter is saved your name and modifiers. FieldDef
Define the characteristics of the fields defined in the module. Each stores information about what their name, type and modifiers.


  • PropertyDef

  • Define the characteristics of the properties defined in the module. Each indicating its name, type, modifiers, and references to items in the table MethodDef methods for set / get.
AssemblyRef ModuleRef TypeRef MemberRef attributes (discussed below) assembly is a logical grouping of one or more modules or resource files (files. GIF,. HTML, etc.) that are included under a common name. A program can access information or code stored in an assembly without having to know what file in particular where they are, so that the assemblies allows us to abstract physical location to execute code or resources we use. For example, we include all types of application on the same assembly, but putting the most frequently used in a certain module and least-used in another, so that only the latest Internet download if you are going to use. AssemblyDef FileDef ManifestResourceDef

EventDef

Sets the characteristics of the events defined in the module. Of each is its name, type, modifiers. and references to items in the table for their methods MethodDef add / remove.

also identifies the external assemblies that are referenced in the module. Each one tells you what the filename (without extension), version, language and mark public key.

also identifies the other modules of the same assembly that references to the module. Each one tells you what the file name.

also identifies the external types which are referenced in the module. From each, it will list your name and depending on where they are defined, a reference to the proper position on the chart or table AssemblyRef ModuleRef.

indicate which members externally defined reference to which the module. These members may be fields, methods, properties or events, and each is stored information its name and symbol, and a reference to the position of TypeRef table that stores information about the type of which is a member.

Table 1

: Main

metadata tables
Note that the significance of the metadata is similar to other pre technologies. NET platform such as IDL files. However, the metadata has two important advantages over these: contains more information and always stored embedded in the module they describe, making it impossible to separate the two. Moreover, as discussed below, may well refer to the metadata of any module through classes

System.Reflection namespace of the BCL

as add additional information by

Assemblies A

All assembly contains a manifest

, which are metadata about the features of the assembly. This manifest can be stored in any of the modules forming the assembly or one specifically created for this purpose, the latter being necessary when only contains resources (satellite assembly

)
The main tables in the manifest are as follows:

Table

Description

Sets the characteristics of the assembly. It consists of a single item that stores the name of the assembly without extension, version, language, public key and algorithm used to find dispersion dispersion values \u200b\u200bFileDef table.

Sets which are the files that make up the assembly. Of each is given its name and hash value. Note that only the module containing the manifest will know what files make up the assembly, but the rest of the file will not know whether or not they belong to an assembly (not contain metadata that tells them if they belong to an assembly)

Define the characteristics of the resources included in the module. Each showing his name, access modifiers. If an embedded resource indicated in the PE where you start that contains it, and if a separate file indicates which element FileDef table for that file. ExportedTypesDef

also identifies the types defined in the assembly and accessible from outside. To save space only capture those who do not belong to the module which includes the manifest, and each stated his name, position in the table FileDef of the file where it is implemented and TypeDef table position corresponding to its definition.


AssemblyProccesorDef

Indicates which processor You can run the assembly, which may be useful to know if the assembly contains modules with native code (it could be done using C + + with extensions managed) are usually empty, indicating that can run on any processor, but if it is full, each item indicate a supported processor type identifier in the format of the file processor Winnt.h included with Visual Studio.NET (for example, 586 = Pentium, 2200 = IA64 architecture, etc.).

AssemblyOSDef


Indicates under what operating systems can run the assembly, which can be useful if it contains modules with types or methods available only in certain systems. Is usually empty, indicating that can run on any processor, but if it were full, indicating the identifier of each of the supported systems following the format of Visual Studio.NET Winnt.h (eg, 0 = Windows family 9X, 1 = Windows NT family, etc..) and the version number of the same from which it accepts. Table 2 digital signature) as the public key needed to decrypt it somewhere on the module to be specified in CLR header. Each time you load it into memory the assembly will be calculated hash value again and check that is equal to the original decoding result using your public key. If not be detected which has corrupted its contents. . The private is stored in the same directory as the application that uses and can only use it while stored in a shared 's actually possible to change both the assembly search policy (for example, to search for private assemblies outside the application directory) as the policy of acceptance of shared assemblies (for example, is made automatically using the new versions of shared DLLs are installed) including the installation directory of the application configuration file in XML format with new rules for them. This file has the same name as the executable of the application but must have extension . Cfg System

: Main boards a manifesto

To ensure that no information has been altered in any assembly is uses the RSA public key cryptosystem. What is done is to calculate the dispersion code SHA-1 module containing the manifest and include both the value encrypted with RSA (
also to ensure that the contents of other files that form an assembly has not been altered so do is calculate the dispersion code to encrypt them before the assembly and save it for each file element in the table FileDef the manifest. The encryption algorithm used by default is SHA-1, although in this case also gives the possibility of using MD5. In both cases, each time you access the file to access a resource type or recalculate the hash value and verify that it matches the one stored in FileDef.

Since public keys are values \u200b\u200bthat occupy many bytes (2048 bits), which is done to prevent the metadata is too large is not to include references to external assemblies AssemblyRef table keys such public assemblies, but only the 64 last bits obtained by applying a dispersion algorithm to those keys. A cut this value is called public key

mark.
There are two types of assemblies:

private assemblies and shared assemblies
global assembly cache (GAC) and can use anyone who has been compiled referenced.

The figures have shared with RSA and identifies what is in the GAC is his name (Without extension) plus your public key, which allows the GAC can be installed multiple assemblies with the same name and different public keys. That is, it's as if the public key part of the name of the assembly, why the assembly and called encrypted

strong name assemblies. This policy allows you to resolve any disputes that attempt to install on one computer shared multiple assemblies with the same name but from different companies, because they have different public keys.
also to avoid problems in the GAC can keep multiple versions of the same assembly. Thus, if an application was compiled using a certain version of a particular shared assembly, when running only be able to use that version of the assembly and not from any other art that had been installed in the GAC. This will solve the problem of DLL Hell

mentioned at the beginning of the topic.
.

Base Class Library (BCL)
The Base Class Library (BCL) is a library included in the

. NET Framework comprises hundreds of types of data that allows access the services offered by the CLR and the most frequently used features when writing programs. In addition, from these classes prefabricated programmer can create new classes by inheritance to extend their functionality and integrate seamlessly with the rest of the BCL classes. For example, implementing certain interfaces can create new types of collections that will be treated exactly like any of the collections included in the BCL.

This library is written in MSIL, so it can be used from any language whose compiler generates MSIL. Through classes provided it is possible to develop any type of application, from traditional windows applications, console or Windows NT service to the novel Web services and ASP.NET pages. Such is the wealth of services offered is even possible to create languages \u200b\u200bthat lack their own class library and is only based on the BCL-like C #.
Given the breadth of the BCL, it was necessary to organize lessons in it included in

namespaces that group classes with similar functionality. For example, the namespaces used are:

Namespace

Utility data types containing

very frequently used types, such as basic types, tablas, excepciones, fechas, números aleatorios, recolector de basura, entrada/salida  en consola, etc. System.Collections


Colecciones de datos de uso común como pilas, colas, listas, diccionarios, etc.




System.Data Manipulación de bases de datos. Forman la denominada arquitectura ADO.NET
.


System.IO

Manipulación de ficheros y otros flujos de datos.


System.Net

Performing network communications.



System.Reflection


access to the metadata that accompany the code modules. System.Security System.Threading System.Web.UI.WebControls System.Windows.Forms System.XML Table 3 Each data type can consist of zero or more members. Each of these members may be a field, method, property or event. Access modifiers are supported: Modifier Code from which the member is accessible

System.Runtime.Remoting

access remote objects.

access security policy on which the CLR.

Thread handling.

Creating user interfaces based on windows for web applications.

Creating user interfaces based on windows for standard applications.

Data Access in XML format.

: Namespaces the most frequently used BCL

Common Type System (CTS)

The
Common Type System (CTS) and Common Type System is a set of rules to be followed by the definitions of data types that the CLR will accept them. That is, although each language has managed its own syntax for defining data types in the MSIL resulting from the compilation of source code must comply with the rules of the CTS. Some examples of these rules are:

can not have multiple inheritance, and all kinds of data must inherit directly or indirectly from System.Object

.

public

Any code

private

same code of data

family code same datatype or his sons.


assembly same assembly code


  • family and assembly code
    same or his sons located in the same assembly
  • family or assembly code
same or his children, or code located in the same assembly The Common Language long string object

Table 4
:

member access modifiers supported by the CTS

Common Language Specification (CLS)

Specification (CLS) and Common Language Specification is a set of rules to be followed by the type definitions are made using a particular language managed if they are to be accessible from any other managed language. Obviously, you only need to follow these rules in the definitions of types and members that are accessible externally and not those of the private. Also, if it does not matter language interoperability is not necessary to follow them. Listed below are some significant rule CLS:

basic data types supported are

bool, char

,
byte, short

, int

,
,

float, double

,
and

as

Note that not all languages \u200b\u200bhave reason support the basic types unsigned integers or decimal type

as does C #.
tables must have one or more dimensions, and the number of dimensions of each table has to be fixed. They must also indexed starting counting from 0.

abstract types can be defined and sealed types. Sealed types can not be abstract members.

Exceptions must derive from System.Exception
, delegates
System.Delegate

, enumerations System.Enum , and value types that are not enumerations of System.ValueType

.


access methods to properties that translate the definitions get / set of these are named the way get_X and

set_X respectively, where X is the name of the property, the indexer access must be translated into methods

get_Item


and
  • set_Item and in the case of events, definitions, add / remove methods to be translated into add_X and remove_X . The only attribute definitions enumeration or data used for the following types: System.Type, string , char , bool , byte, short , int ,
  • long
    ,
    float, double
    and
  • object. In the same area can not define multiple identifiers whose names differ only in the capitalization used. This will avoid problems when accessed using non-sensitive languages to uppercase. Enumerations can not implement interfaces, and all fields must be static and the same type. The type of the fields in a list can only be one of four basic types: byte, short
  • , int or long . (C) 2001 Jos? Antonio Gonz? Lez Seco