Saturday, January 26, 2008

What's The Pay For T Mobile Call Center Employee

The programming language C #. Lexical aspects.

Author: José Antonio González Dry
Full course available
DOC and PDF formats on the author's web .

Comments

A comment is text that is included in the source code to facilitate reading for developers and content is, by default, completely ignored by the compiler. Often used to include information about the author of the code, to clarify the meaning or the why of certain sections of code to describe the performance of the methods of classes, etc..

In C # there are two ways to write comments. The first is to enclose all the text you want to talk among characters / * and * / using the following syntax:
  / *  \u0026lt;text>  * /  
These comments can span as many lines as necessary. For example:
 / * This is a comment that illustrates how to write Comments that span multiple lines * / 
But be careful with the fact that you can not nest comments of this kind. That is, it does not write comments like the following:
 / * Comment container / * comment string * / * / 
This is because as the compiler ignores all the text in a comment and just looking for the sequence * / that marks its end, ignore the second / * and when you reach the first * / deemed to have finished with the first open comment / * (not open to the second) and will search code. As * / only supported if detected before any comments yet open and closed (while not looking code), when you reach the second * / deemed to have been a mistake and you will find the * / where he hoped to find code .

Since many times the comments are written are very short and do not usually occupy more than one line, C # provides an alternative syntax more compact for writing these kinds of comments in which is considered an indicator of the beginning of the comments the couple character / / and as an indicator of an end to online. Therefore, the syntax is following these comments:
 / / \u0026lt;text> 
And an example of its use is:
 / / This comment illustrates how to write comments shortcuts 
These single-line single-line comments themselves can be nested without any problem. For example, the comment is perfectly valid:
 / / Comment wrapper / / Comment 
content Continue Reading ...

Identifiers

As in any programming language in C # an identifier is just as its name suggests, a name that will identify some element of our code, either a class, variable, method, etc.

Typically the name of an identifier is a sequence of any number of alphanumeric characters, including accented vowels and ñ-such as the first of them is not a number. For example, valid identifiers are: Up, cane, C3P0, AEIO, etc., but it would 3com, 127, etc.

However, although for reasons of readability of the code is not recommended, C # also allows you to include in a printable handle special characters such as umlauts symbols, underscores, etc. provided they do not have special meaning within language. For example, would also be valid identifiers, _barco _ , C "k A • B but not C # ( # indicates start preprocessor directive) or! B (! indicates logical" not ")

Finally, C # gives the possibility to write identifiers that include Unicode characters that can not be printed using the keyboard of the machine controller or may not be directly valid because they have a special meaning in language. To do this, it is permitted to enter these characters using escape sequences , which are nothing that sequences of characters with the syntax:
  \\ u  \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> or  \\ U  \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> ; \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> \u0026lt;dígito> 
These digits indicate the Unicode character you want to include as part of the identifier, and each of them has to be a digit valid hexadecimal. (0-9, af or AF) should be noted that the character has or write in lowercase when Unicode characters are indicated with 4 digits and uppercase characters when they are shown with eight. Examples of valid identifiers are C \\ u0064 (equivalent to C #, since 64 is the code # in Unicode) or a \\ U00000033b (equal aa! B>)


reserved words

Although previously have been a number of restrictions on what are the valid names can be given in C # for the handles, is still to give, the following nombres no son válidos como identificadores ya que tienen un significado especial en el lenguaje:
  
abstract, as, base, bool, break, byte, case, catch, char, checked, class,
const, continue, decimal, default, delegate, do, double, else, enum, event,
explicit, extern, false, finally, fixed, float, for, foreach, goto, if,
implicit, in, int, interface, internal, lock, is, long, namespace, new,
null, object, operator, out, override, params, private, protected, public,
readonly, ref, return, sbyte, sealed, short, sizeof, stackalloc, static,
string, struct, switch, this, throw, true, try, typeof, uint, ulong, unchecked, unsafe, ushort, using, virtual, void, while
Apart from these reserved words, if in future implementations of the language is decided to include new keywords, Microsoft said that those words would have to include at least two consecutive underscore symbols ( __>) Therefore, to avoid possible future conflicts is not recommended to give our identifier names containing the sequence of symbols.

Although we can not directly give these names to our IDs, C # provides a mechanism to do so indirectly and in a much more readable than using escape sequences. This mechanism is to use the character @ to prefix the name coincides with a keyword you want to give our variable. For example, the following code is valid:
 class @ class {static void @ static (bool @ bool) {if (@ bool) Console.WriteLine ("true") else Console.WriteLine ("false");}} 
What has been done in the previous code has been used @ to declare a class named class name with a static method that takes a bool parameter name, even if all these names are reserved words in C #.

should be noted that although the name we write is for example @ Class, the name that the compiler will treat it only internally to handle class. In fact, if from code written in another language adapted to. NET than C # we refer to this identifier and the language its name is a reserved word, the name by which we reference it is class, not @ class (if also be in that language reserved word should be referenced with the mechanism that the language included for this, which perhaps could be used @ and C #)

In fact, the use of @ there is no reason to limit to precede reserved words in C #, but we can precede any name with him. However, doing this is not recommended because it is considered a bad programming practice and can cause subtle errors such as that shown in the following example:
 class A {int a; / / ( 1) int @ a / / (2) 
public static void Main () {}}
If we try to compile this code will fail to inform us that the name field has been declared many times in class A . This is because as @ actually not part of the identifier name to the above, the statements marked with comments like (1) and (2) are equivalent.

should be noted, finally something about the character @ : You can precede the name of an identifier, but can not be contained within it. Ie i5322@fie.us.es identifiers as invalid.




Literals A literal is the explicit representation of the values \u200b\u200bthey can take the basic types of language. Here's what the syntax literals are written in C # broken down by type of values \u200b\u200bthey represent:

  • Literals integers: An integer can be represented in C # as a decimal or hexadecimal. In the first case, you write the decimal digits (\u0026lt;0-9) the number one after the other, while the second is to precede the hexadecimal digits (0-9, af, AF) with the prefix 0x . In both cases it is possible to precede the number of operators or + - to indicate whether positive or negative, although nothing is placed shall be considered as positive. Examples of integer literals are 0, 5, +15, -23, 0x1A,-0x1a, etc.

    Actually, the complete syntax for writing can also integer literals include a suffix indicating the integer data type that must belong to the literal. This will not see until Item 7: Variables and data types .

  • real literals: Real numbers are written in a manner similar to the integers, but can also be written in decimal form and to separate the integer part of real use traditional decimal point ( character. ) may also represent real scientific format, being used to indicate the exponent characters > e or E . Real literal examples are 0.0, 5.1, -5.1, +15.21, 3.02e10, 2.02e-2, 98.8E +1, etc.

    As was the case with the literal integers, real literal may also contain suffixes that indicate the real data type they belong to, but we will not see again until Item 7: Variables and data types

  • Logical literals : The only valid literals are logical and true false , which respectively represent the logical values \u200b\u200btrue and false.

  • character literals: Almost any character can be represented by enclosing it in single quotes. For example, 'a' (letter a), '' (Space character), "?" (Question mark), etc.. The only exceptions to this are the characters that are shown in Table 4.1, to be represented by escape sequences to indicate its value as a Unicode code or by a special format as shown below
Character

Unicode escape code

Code

special exhaust

Single quote

\\ u0027

\\ '

double Comilla

\\ u0022

\\ "

null

\\ u0000

\\ 0

Alarm

\\ u0007

\\ a

Reverse

\\ u0008

\\ b

Page Break

\\ u000C

\\ f

New Line

\\ u000A

\\ n

Carriage return

\\ u000D

\\ r

Horizontal tab

\\ u0009

\\ t

Vertical tab

\\ u000B

\\ v

Backslash

\\ u005C

\\ \\

Table 4.1: special escape codes



In fact, in the above table should be completed the double quote character can also appear within a string literal directly, without using sequence escape. Therefore, other literal examples of valid character will be '\\ "', '"', '\\ f', '\\ u0000', '\\ \\', '\\'', etc. Besides

to represent the characters in the table above, it is also possible to use Unicode escape codes to represent any Unicode code, which is often used to literals representing characters not included in standard keyboards. Along the

representation format Unicode escape codes already seen, C # includes a shortened format for these codes represent in the literal character if ever need to write even though the four-digit code to represent have many zeros in the left side. This format is to precede the code \\ x instead of \\ u . Thus, the literal character '\\ U00000008', '\\ u0008', '\\ x0008', '\\ x008', '\\ x08' and '\\ x8' are all equivalent. Keep in mind that this short format is only valid in character literals, not when naming identifiers.
  • String literals: A chain is not just a sequence of characters enclosed in double quotes. For example "Hello World", "truck", etc.. The text contained within these literal can consist of any number of concatenated character literal without the single quotes, double quotes even if it includes these must be written using escape sequences because otherwise the compiler would interpret as the end of the chain.

    Besides writing format string literals before mentioned, which is commonly used in most programming languages, C # also supports a new one consisting of a symbol precede @ case that the entire contents of the string would be interpreted as-is without considering the existence of escape sequences. This type of literals are called string literals or plans verbatim verbatim and can even span multiple lines. The following table lists some examples of how to interpret:

    String Literal

    Interpreted as ...

    "Hello \\ tMundo" Hello

    World

    @ "Hello \\ tMundo"

    Hello \\ tMundo

    @ "

    Hello World" Hello

    World

    @ "" Hello World "

    " Hello World "

    Table 4.2: Examples flat string literals


    The latest example of the table has been used to show that if within a string literal plane to include double quote characters without being confused by the end of the string simply duplicate them.
  • Literal Null: The literal null is a special value that is represented in C # with the keyword null and used as the value of the object variables are not initialized in order to indicate that they contain references nil.

Operators

An operator C # is a symbol consisting of one or more characters that allows a particular transaction between one or more data and produce a result.

following describes what the operators included in the language, classified by type of operations that allow, although we must bear in mind that C # allows the redefinition of the meaning of most of the operators by type of data on the to be applied, so that what is told here corresponds to the most common uses of them:

  • Arithmetic: Arithmetic operators included in C # are the usual addition ( +> ), subtraction ( - ), product ( *), division ( / ) and modulus (% ) operators are also included "less unary ( - ) and "more unary ( + )
    Related
    arithmetic operations are a couple of operators called checked and unchecked that control in order to capture the overflows that can occur if to perform such operations, the result is greater than the capacity of the data type of its operands. These operators are used as follows:
      checked ( \u0026lt;expresiónAritmética> )   unchecked ( \u0026lt;expresiónAritmética> )  
    Both operators \u0026lt;expresiónAritmética> calculate the result and return it if during the calculation does not occur no overflow. However, in case of overflow each works in a different way: checked causes a compilation error \u0026lt;expresiónAritmética> is a constant expression and an exception System.OverflowException if not, while unchecked returns the result of arithmetic expression truncated to fit the expected size.

    By default, in the absence of operators checked and unchecked what is done is to evaluate the data arithmetic operations between constants as if applied to them checked and data operations between constants as they had applied unchecked.
  • Logical operations: operators are included which allow the typical logical operations "and" ( & & and & ), "or" ( while the lazy evaluation is not always evaluate both operands. That is, if the first operand of an operation & & false returns false directly, without evaluating the second, and if the first operand of a ), "greater than or equal" (> = \u200b\u200b) and "less than or equal to (\u0026lt;=)

    bit manipulation operations : have including operators that allow bitwise operations "and" ( & ), "or" ( ) operator \u0026lt;\u0026lt;
      move to the left padding with zeros, while the fill rate by
    >>
    depends on the type of data on which to apply: if a signed data maintained sign, otherwise padded with zeros.
  • Operations assignment: used to make assignments in C # = operator, operator in addition to the assignment that prompted returns the assigned value. For example, the expression a = b assigned to the variable to the value of the variable by returns that value, while the expression c = a = b assigns the value of variables c and b (= operator is right associative) Also included are compound assignment operators that save typing when performing assignments as common as temperature = temperature + 15, / / \u200b\u200bnot use compound assignment temperature + = 15; ; / / Using Compound Assignment The two lines are equivalent, since the composite operator + =
    assigned to the first operand plus the value it had its second operand (ie, adds the second operand) As you see, allows very compact code. Besides
  • compound assignment operator + = also offer compound assignment operators for most binary operators already seen. These are: + = , -=, *= , / = , % = , & = , these lines of code are equivalent: temperature = temperature + 1, / / \u200b\u200bnot use compound assignment or increased temperature + = 1; / / Using temperature compound assignment + + / / Using If the operator increases + + is placed after the name of the variable (as in the example) returns the variable value before increasing it, whereas if placed before it returns the value after increasing, and so does the operator - . For example: c = b + + / / is assigned ac value by then increases bc = + + b / / It adds value by then assigned ac The advantage of using operators
  • + +
and
    -
  • is that many machines are more efficient than other ways of doing addition or subtraction of a unit, because the compiler can translate into a single instruction in machine code. String Operations: To perform string concatenation can use the same operator to perform addition, since in C # has redefined its meaning so that when applied between operands are strings or to be a string and a character that does is concatenate. For example, "Hello" + "world" returns "Hello World" and "Hello World" + "or" too.

     
    access operations tables: Table

    A is a set of objects larger ordered fixed. To access any element of this set is applied postfix operator [] on the table to indicate in brackets the position of the object you wish to access within the set. That is, this operator is used like this: [\u0026lt; posiciónElemento> ] An example of its use in allocating the element that occupies position 3 in a table of name value tablaPrueba the element at position 18 of the table is as follows: tablaPrueba [3] = tablaPrueba [18]; Tables studied in detail in Item 7: Variables and data types Conditional Operator: is the only operator on C # that takes 3 operands, and is used as follows:

    \u0026lt;condition> ? \u0026lt;expresión1> :
     \u0026lt;expresión2> 
    The significance of the operation is as follows: Evaluate \u0026lt;condition> If true returns the result of evaluating \u0026lt;expresión1>, and if false returns the result \u0026lt;condición2> evaluate. An example of its use is: b = (a> 0)? a: 0; / / Assume a and b integer types In this example, if the value of the variable is greater than 0 is assigned to ab value, while otherwise the value assigned is 0. Keep in mind that this operator is right associative, so an expression like? B: c? D: e is equivalent to a? B: (c? D: e)
     
    should not be confused this operator with the conditional statement if to be treated in the Item 8: Instructions , because although its usefulness is similar to it,
  • ? And returns
  • if not. Operations delegates
  • A
delegate is an object that can be stored in a reference to one or more methods and through which you can call these methods. To add to a delegate is used by operators and
  • + + = , while that to remove the operators used - and -= . These concepts will be studied carefully in Item 13: Events and delegates
         
     
    object access operations: To access the members of an object is used
  • operator.
, whose syntax is:
  • \u0026lt;object> . \u0026lt;member> If an object is, examples of how to call different members of it are: ab = 2, / / \u200b\u200battach to your property to a value of 2 f (); / We call the method f () g (2), / / \u200b\u200bcall to method g () passing as parameter the integer value 2 Do not worry if you do not know the concepts of methods, properties, events and delegates in which based this example, as explained in detail in subsequent issues.
       Operations   
    pointers: pointer
     


    A is a variable that stores a reference to a memory address. To obtain the memory address of an object using the operator
    &
    to access the contents of the memory address stored in a pointer operator is used * to access a member of an object whose address is stored in a pointer used -> , and to reference a memory address of a pointer on how we apply the operator [] form pointer [offset]. All these concepts are explained further in the Item 18: insecure code.
  • operations to obtain information on types: Of all the operators that allow us to obtain information about data types the most important is typeof , whose method of use is: typeof ( \u0026lt;nombreTipo> ) This operator returns an object of type System.Type with information on the type of name \u0026lt;nombreTipo> we can see through the members provided by the object. This information includes details such as what its members, what is your kind father or which namespace it belongs.
If we want to determine whether a given expression is of one kind or another, then the operator is using is
  • , whose syntax is: is \u0026lt;expression> \u0026lt;nombreTipo> The meaning of this operator is: \u0026lt;expression> evaluated. If the result of this is the guy whose name is indicated on \u0026lt;nombreTipo> returns true , and if not, returns false
     . As discussed in the  Item 5: Classes 
    , this operator is often used in polymorphic methods.
     
    Finally, C # incorporates a third operator that allows information about a data type:
  • sizeof
  • This operator giving the number of bytes that will occupy in memory objects of a type, and is used as follows: sizeof ( \u0026lt;nombreTipo> ) sizeof can only be used in unsafe code, which for now is enough to consider which are areas of code where you can use pointers. Will not to Item 18: Code insecure when they discuss in depth. also sizeof can only be applied to names of data types whose objects can be stored directly on the stack. That is, they are structures (will be in Item 13) or enumerated types (you will see in the Item 14)
  • Operations object creation: The operator more typically used to create objects is new, used like this: new
     \u0026lt;nombreTipo>  (   \u0026lt;parameters> 
    )

    This operator creates an object of \u0026lt;nombreTipo> passing to the constructor method parameters in \u0026lt;parameters> and returns a reference to it. Depending on the type and number of these parameters will be called either of the constructors of the object. Then if a1 and a2 are variables of type airplane, examples of using the new operator are
     Airplane a1 = new Airplane () / / constructor is called Airplane parameters a2 = new Airplane ( "Hunting"); / / Constructor is called Airplane taking ; ; ; / / As a string parameter  If the type has been called for the creation of the object is a class, it will be created on the heap, and what new  


    will return a reference to the stack address which stores a reference to the direction of the object on the heap. However, if the object to create a structure or part of an enumerated type, then it will be created directly on the stack and the reference returned by the new will refer directly to the object created. For these reasons, classes are called reference types as their objects on the stack only stores a reference a dynamic memory address where we really are, while the structures and enumerated types are known as value types and their objects are stored directly on the stack. C # provides another operator also allows us to create objects. This is
    stackalloc
    , and is used as follows: stackalloc \u0026lt;nombreTipo> [
     \u0026lt;nElementos> ]   This operator it does is create a table cell so many elements of type \u0026lt;nombreTipo> \u0026lt;nElementos> as directed and return the memory address it has been created. For example: int * p =  stackalloc [100] / / p points to a table of 100 integers. 
    stackalloc only be used to initialize pointers to objects of value types declared as local variables.

    Operations conversion: To convert a other objects using the conversion operator, which is about that precede the expression to convert the name in parentheses the type that you want to convert the resulting evaluation. For example, if l is a variable of type long
and to store its value in a variable of type
  • int i call, would be converted before its value type int well:
     i = (int) l / / assign i the result of converting the value of type int int    types   and long   > 

    are predefined in C # and can store integer values.

    capacity
    int is 32 bits, while the long is 64 bits. Therefore, unless we use the conversion operator, the compiler will not let us do the assignment as being more the capacity of long
     
    Not every value that can be stored in a long is why being able to store an int . That is, not true: i = l, / / \u200b\u200bERROR: The value of l does not have to fit in i This restriction is imposed on the allocation because the compiler could occur without it very difficult to detect errors before truncation unexpected because the value of the variable source is beyond the capacity of the target variable. There is another operator which perform conversion very similar to that already seen. This is the operator
    as
    , which is used as follows: \u0026lt;expression> as
     \u0026lt;tipoDestino>  What it does is return the result of converting the result of evaluating the rate indicated in \u0026lt;expression> \u0026lt;tipoDestino> For example, to store in a variable p the result of converting an object type t Person you would type:  Person as p = t;  The only differences between using one or another conversion operator are:    
     as 
    only applies to reference types and only those cases where there are predefined conversions language. As discussed below, this only includes conversions between a guy and his parents and between types a type and types his children. One consequence of this is that the programmer can define how to do type conversions defined by him and others through operator () , but not by as
. This is because as
  • only indicates that you want a reference to an object on the heap is treated as if the object were otherwise, but does not involve any conversion. However, () itself implies \u0026lt;tipoDestino> conversion if it is not compatible with the type of object referenced. Obviously, the operator will be applied much faster in cases where it is not necessary to convert. If requested to do a conversion as invalid returns null while () throws a System.InvalidCastException . (C) 2001 José Antonio González Seco
     
    addthis_url = ''; addthis_title = ''; addthis_pub = 'igner';

0 comments:

Post a Comment