Sunday, October 3, 2004
Microsoft proposed CLS (CommON Language Specification, General Language Standard) provides a regular setup of the smallest function set that can be used to write a DotNET program. Take C #, it is a product of the current programming language "with efficiency" development trend. "Compiler" transitions all programs to machine code that will be executed by the computer; the machine code forms a "executable file", which can be run directly on the computer. However, because the machine code is associated with a particular computer, the executable can only be executed on a specific type of computer. Traditional procedural procedure design language (such as c), data will be processed by the process (or "function" "subroutine") code; in the object-oriented programming language, the programmer creates a variety of "classes", and thus Derived "objects", an object is a mixture of code and data, and data is processed by the object itself. This concept greatly improves the "reuse of the code". In the 1990s, Sun launched Java, which has a significant difference between C with C . Java abandoned C some difficulty and difficulty, and also eliminated some dangerous C language functions, but it retained the simple and compact characteristics of C language. A "OperaReater is a symbol or word that will make a specific operation of a particular action; in the C # and many other modern programming languages, the program code must be written as a" class "and" method "unit. . The simplest C # program contains only one class, which only contains only one method - "Main () entry function. A method statement will be a modifier, a return value type (SUCH AS VOID), a method name, a list of input parameters enclosed in a pair of parentheses, a statement block containing the method code body, etc. Composition. One method is a set of program code to complete a particular task. An expression can be a variable, a constant or an operational or calculation result. When C # is used to make two integers, it will "truncate" Fortunately, there is a lot of money (%) make up.
Tuesday, October 5,2004
Expression is constructed by operand and operators. An expression has his value, so the expression can make another representation of another expression. C Family important characteristics, refined, less typing. "Composite assignment" operator: = plus, etc .; increments; - decrement; ... C # compiler special function: appear in front of the class, method or other program structure element and three Note from the slash "///" allows to include XML tags. The C # compiler will generate an XML file to store these tags. In today's digital computers, various information will be encoded as a series of "bits"; bits are the simplest representation of information. The computer hardware voltage is high or there is a bit; today's personal computer is mostly 32-bit computers because they use 32-bit as a basic unit for storage and processing of data. Early computers can only handle 8 bits each time, people call 8 bits as one byte. Even today, bytes are still the most common measurement unit in the computer. C # uses 32 bits (4 bytes) to represent an int type variable. An int can be used to store positive and negative numbers, so INT is officially defined as "32-bit strip symbol integers". The binary number is indicated by the power of 2, and the n power of 2 is a binary number 1 followed by a binary number composed of n 0. For example: 1-0000-0000 is equal to 256 or 28 modern digital computer, negative numbers are often expressed as "binary complement". Binary complement refers to a method for converting positive and negative numbers. To indicate -7 (assuming only 4 bits, the first one is a symbol bit): first served 7 binary representation: 0111, then put 0111 to take the anti-plug-in "complement" 1001, 1001 -7 C # key Word checked and unchecked activation overflow check mechanism C # supports 8 integer data; the basic principle of integer data: @ 97% Priority Consider using int types, 32-bit easy processing is also more efficient @ 数值 大, only Long @ If you need to use a disk file to store or retrieve a large number of small integers, consider using Shot, Byte save space fields and methods, they are all members of a class or a structure, but the field is much simpler. A field is actually a variable or a constant that is fixed. Thursday, October 7, 2004
In a complex statement involving a variety of arithmetic, C # will convert the necessary types of operands to each of the operations according to the priority and calculation rules of the operator (small capacity to large capacity transfer). In assigning operations, the expression on the right side of the equal sign will be implicitly converted to the type of variables such as the left. Method Overload is a plurality of different versions of a method. If the method signature of the console.writeline () method (ie, the input parameter) can be an integer or a string. Similarly, operator overloading refers to the practice of different types of operations with the same operator. If the plus " " is used as a numeric addition and string merge. "Quotation marks in the string" problem:
Change the normal meaning of characters with escape characters such as: string stringwithquotes = "the name of the composition is /" appalachian spring./ "; use" @ "to refresh the escape, such as: string directory = @" C: / Program Files / Key of c # "; distribution in memory (clear storage parts)
Code area: Storage program code, various function code blocks of the program; global data area: store global data and static data; stacking area: Storage program's dynamic data; Data; especially the data of the stack area, the function will be released. "Reference" in C # is not a "pointer" in C / C , it is a secure "reference pointer", with C / C "pointer" Complete similar operations. The specific data content of the reference type data (such as class) is saved in a memory block allocated from the heap, while the reference pointer of this memory block is saved on the stack. Understand the difference between NULL and empty strings from memory allocation: The reserved word null is a reference pointer with a value of 0, which means that C # will not allocate memory in multiple piles. A string variable that is useless to reference any pile of memory is called a "NULL string". When a string variable is assigned NULL, C # does not assign any memory from the heap and the value corresponding to it on the stack is 0; when a string variable is equal to the empty string, C # will be from the heap I allocate some memory for it, but the string length is 0. Text is the main medium that communicates with computers. People "Force" computer displays text output and accept text input. Even if only the value is displayed, the computer must also convert the binary representation of each associated value into the corresponding text output form. INT and String Transfer:
TOSTRING is an instance method: string str = 123.toString (); // Existential INT32.PARS is a static method: int i = int32.parse ("123"); // Create an instance system The namespace also has a very easy Convert class. The programmer can convert any two data types using the various static methods provided by the Convert class. Such as: int i = convert.Toint32 (STR); string str = convert.toString (i); C # two non-oort data types: floating point and Decimal
The floating point is very common, but there is a congenital deficiency, it is not enough (Float seven effective numbers, double there are 15 or 16) compared to int and uint (32-bit), long and ulong (64-bit), Decimal use 128 Bits 16 bytes store data; where 96 bits are used to represent effective numbers (29), 5-digit decimal point positions (0-28), one symbolic bit, a total of 102 yuan 26 bits.
SATURDAY, OCTOBER 9, 2004
Decimal rounding
"Since 20 into": decimal.truncate (value); // Roll into zero direction Decimal.floor (Value); // round to the endless direction "rounded as an even number": decimal.Round (value, digits); / /Round (3.345, 2) = 3.34 Format string consloe.writeLine ("{0,20: x5} {1, 10: C2}", str1, str2); // {placeholder, output width: format} Word "static" indicates that the method is a static method, which will act on a particular method of classes or structures rather than acting on classes or structures, which must be used with the names of the class or structure, such as console.writeline (); The field is internally, but the variable or constant declared in the outside of all methods in this class. If the field is only associated with this class, it is not associated with the instance of the class, declares that it is static Static. NEW reserved role: The return value of the New Expression is a reference (pointer), which refers to the memory block allocated from the heap. Such as: int [] aviaray = new int [] further understands the role of New: Clearly assign space random rand in the heap; // rand is not initialized, nothing is rand = new random (); // is RAND C # not allowing you from a heap allocation of memory and initialization operations to declare an array with a reserved word const - only if the value determined or calculated in the compilation phase can be declared as a constant; the array requires a new operation, and the New operation is only waiting The run phase will happen. A basic principle of programming - "Put the variable, regardless of the array or other type of variable, as local variables as possible"; but when you need to call a certain method in a program, this method should be used When the element is a constant array, the array should move that array to the outside of the method and declare it as a Static field. The Random class supplier of .NET is used to generate random numbers from that random seed.
Monday, October 11, 2004
Logical formula - De Mogan Law:
! (A | b) =! A &! B! (A & B) =! A |! BC # in the char data type: Represents a single character in C #, you can create a string with a character array, too You can convert a string to a character array, but a C # string is unappropriate to be a character array. C # has a string data type String. All programming languages are characterized by values, but C-language regards char than what is different from int, short, and long. In C, the width of char is 8 bits and represents an ASCII character, but in C #, the width of Char is 16 bits and represents a Unicode character. The CHAR variable in C # is not a value. String.Chars properties in C #, this property is the indexer of the String class. Gets characters located in the specified character position in this instance. New constructor's understanding If you want to create a string that makes up from 21 "@" characters, what do you do? String str = "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@0000@@@@@@@0000- ornaive?" @ ', 21); // Simple and smart