Author: kemin's booootlog http://blog.9cbs.net/keminlau/
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
Wednesday, October 13, 2004
Comparison of floating point numbers
Comparing floating point numbers, it must be first re-performed for the same accuracy, because of its inactivity. When you need to test if a FLOAT value or a double value is infinite or NaN, you cannot use the PositiveInfinity, NegativeInfinity, or Nan fields in the Single or Double Contribution; should be done by IsInfinity. It is recommended that it is best not to use the "==" operator to compare two Boolean values, because it is not careful to play a equal sign, will be fatal. You can use the different or operator "^" will be more secure. There is a "! =" Operator equivalent, so many people call "^" as logic "not equal" operators. As long as the result of "^" operator pairs "! =" Operation can be used to obtain the same effect as "==" operator, such as: bweareCompatible = byoulikemahler == bilikemahler bWeareCompatible =! (Byoulikemahler ^ Bilikemahler) The local variable is only visible only in the {statement block} that is declared. How big is this statement block, and it is checked .... C # There is no "ELSE statement", the IF statement in the C # is constructed of one IF portion and an optional else section. C # also has no "ELSE IF statement", which is two IF combinations. Conditional operator
Conditions & (&&) with conditions or (||)
BEXPRESSION1 & BEXPRESSION2 // If the bexpression1 is evaluated for false, BEXPRESSION2 will not be evaluated BEXPRESSION1 || BEXPIRESSION2 // If Bexpression1 is evaluated to true, BEXPRESSION2 will not be evaluated to be quirky "conditional expression" (?: ), Unique three mesh operators. First, C # exception handling is used to keywords
TRY is used to check an exception that occurs and helps send any possible exceptions. Catch handles errors in a larger way to control, and you can have multiple CATCH clauses. Finally's code blocks will be executed regardless of whether abnormalities have caused an exception.
Throw is used to trigger an exception, which can trigger predefined exceptions and custom exceptions. Second, C # abnormal processing format
The following is a reference fragment: try {program code block;} catch (exception e) {exception handling code block;} finally {The code block to be executed regardless of whether there is an abnormality, the code block to be executed;} effective debugging skills No wireless net fish SHOULD NEVER Be EXECUTED. "The FOR statement starts with the word" for ", followed by a pair of parentheses, there are three brackets separated by a semicolon. Note that this is where the semicolon is not treated as a statement separator in C #! These three expressions are called "initialization expressions", "cycle conditional expressions", and "step-by-step expressions", respectively, called FOR cycles.
Friday, October 15, 2004
The algorithm "Sieve of E ERATHENCES" is an algorithm for generating the number of encompasses. The number of entries can only be 1 and its own integer. 2 is the number of first prime, and it is the only one of the numbers. CPU time-consuming comparison: Method call> Ride calculation> Adjustable Switch statement in Java, Switch statement can only handle integers. However, the Switch statement in the C # is different, and it can also handle the character variable.
Switch (ARGS [0]) {CASE "boss": console.writeline ("Good morning! We are ready for you!"); break; case "employee": console.writeline ("Good morning! You can start working ! "); Break; default: console.writeline (" Good morning! I wish you good luck! "); Break;} Different from Java, the C # Switch statement requires every Case block or at the end of the block A Break statement, or use Goto to another CASE tag within Switch. This is the so-called "not allowed to leave the SwICTH branch funnel", but you can make a Switch branch with multiple Switch labels. Such as: .... Case "*": // Multiple multiplication operators Case "X": // Case "X": // Dresult = DNUM1 * DNUM2 BREAK; .... Write C # program "Basic Tools ":
Declare statement; assignment statement; select statement (if, switch); // they enable the program to selectively change the execution route cycle statement (While, Do, For, Foreach) based on a comparison operation or other Boolean operation. They enable the program to perform the same statement multiple times. Jump statement (Return, Break, Continue, Throw, Goto); // They make the program to run from one place to another place to continue. C # Nothing >>> Shift operator C # supports unsigned variable types such as UINT and ULONG. Therefore, in C #, the right shift operator (ie, ">>") is different for unsigned variable types and symbolic variable types (such as int and long). Right shift UINT and ULONG discard the low and set the empty high position to zero; but for the INT and long type variables, ">>" operator discard the low position, while only when the variable value is positive, ">>" Set the empty high level to zero; if ">>" is a negative number, the high level of the empty out is set to 1. There is no symbolic variable type in Java. Therefore, we use the ">>>" operator to introduce the negative position at right time; otherwise, use the ">>" operator. Enumerator enumerator is an ENUM type (Enumerator, or a counter), it is a collection of related constants. Accurately, the Enum type declares a set of related symbol constants define a type name. For example, you can create an enumerator called FRUIT, use it as a type of variable value, thereby limiting the possible range of variables to the value that appears in the enumerator.
PUBLIC CLAIT DEMO {Apple, Banana, Cherry, Durian} Public Void Process (Fruit Fruit) {Switch (Fruit) {Case Fruit.Apple: ... Break; Case Fruit.Banana: ... Break; Case Fruit.Cherry: ... Break; Case Fruit.durian: ... Break;}}} Sunday, October 17, 2004
C # method calls passing parameters four categories:
The default value parameter (VALUE parameter); // transfer replica reference parameters, keyword "ref"; // transfer reference pointer output parameters, keyword "OUT". / / Method Returns an array parameter (Array Parameter), the keyword "params" reference parameter and output parameters when returning one or more return values: "Reference Parameters" is very similar to "Output Parameters". OUT modifier Ref modifiers have similar places: an address. In fact, the realization of the word "ref" and "out" itself is exactly the same in the intermediate language. However, the REF parameters in C # are still different from the OUT parameters:
The REF parameter must be assigned before entering the method; the OUT parameter must be assigned before leaving the method. Need to remember that the output parameter has a certain difference between the return value of the usual function: Function return value often exists in the stack, pops up when it returns; and the output parameter requires the user to pre-store the storage location, that is, the user needs to declare the variable in advance - of course also Can be initialized.
using System; class Test // Name resolution {static void ResoluteName (string fullname, out string firstname, out string lastname) {string [] strArray = fullname.Split (new char [] { ''}); firstname = strArray [ 0]; LastName = stratay [1];} public static void main () {// string myname = "cornfield lee"; console.writeline ("Enter your name:"); string myname = console.readline (); string MyFirstName, MyLastName; ResoluteName (MyName, out MyFirstName, out MyLastName); Console.WriteLine ( "My first name: {0}, My last name: {1}", MyFirstName, MyLastName);}} array parameter (keyword " Params ")
Using system; class test // Total all integer value {static int sum (params int [] args) {INT S = 0; Foreach (INT N IN ARGS) {s = n;} Return S;} static void main () {Int [] var = new int [] {1, 2, 3, 4, 5}; console.writeline ("the sum:" sum (var)); // 传 传 组 变 CONSOLE.WRITELINE ("The Sum : " SUM (10, 20, 30, 40, 50)); // Biography can implicit into arguments parameters}} Note the following two regulations: array parameters can only be one-dimensional; if there are multiple inputs Parameters, only one input parameter is parameters, and it must be the last one in the parameter table.
Tuesday, October 19, 2004
Data packaging - object
In essence, the object is data. As the programming language is developing, when people began to combine different data together and treat them as a whole thing, "object" is born! (Take a date object is understood) When declaring variables and constants, your program is actually an object, numerical constant and string are objects. However, with your program really implemented the statement, the object is not "born". Date Object: The date is organic as a combination of three discrete digital variables, which greatly simplifies the processing of date data. The New operator will allocate memory for the new instance and initialize all the fields of it into 0; the pile is always initialized 0 (that is, the stack is a value of 0 or null null). Date [] adate = new date [5];
If DATE is a structure: This statement will allocate the memory from the 5 instances of this structure (no need to initialize, the instance is required) from the heap, and the instance is now initialized to 0; if it is a class, This statement will only allocate memory only for this array itself (above the array of components, but also assign structural instances). Each element of this array will be NULL. Because each element of this array is a reference (pointer). Before using this array, you must first use a New constructor (including allocation memory and initialization): adate [3] = new date (); C # array is a reference type, each element in array will be stored in the stack . Such as int [] ai = new int [12]; // use the new keyword to save the array in the Heap assignment, C # has the following reference type: the execution efficiency of the stack is higher than the execution efficiency of the stack, but the resource of the stack is limited. Not suitable for handling large logic complex objects. Therefore, structural processing as a small object treated by the base type, and the class handles a business logic although the initialization of the structure also uses the New operator, but the structural object is still allocated on the stack instead of the pile, if "New" is not used (New " The field will remain unfamed before initializing all fields, and how objects do not use how to select structures or classes to discuss the structure and differences of the structure, how to choose how to use the structure or class:
The stack is limited, for a large number of logical objects, the creation class is to represent a lightweight object such as a bit, rectangle, and color than the creation structure, for example, if an array containing 1000 point objects is declared, Quote Each object assigns additional memory. In this case, the cost of the structure is low. When performing abstract and multi-level object hierarchies, the class is the best choice. When this type is just some data, the best selection is the best-oriented process to the object-oriented three steps: Packaging object simplifies the input parameter list:
Static int dayofyear (int iod) {....} // three integer input parameters static int dayofyear (Date DDATE) {....} // Date is like a predefined Good simple type. The encapsulation is related to the object to the class (or structure), becoming a class (or structure) behavior, further sharing code: distinguish between classes (or structure) methods and field staticity and examples, further simplifying the object Code. Every class of .NET Framewrok and each structure TOSTRING method, the self-defined classes and structures are no exception, because all classes and structures in C # are inherited from the same ancestor --system.Object class. Although the structure does not support inheritance, all structures are inherited directly or indirectly from the System.ValeType class. If the declaration of an instance method contains a Virtual modifier, the method is called a virtual method. If there is no Virtual modifier, the method is called a non-virtual method. The implementation of the non-virtual method does not change: Whether in the instance of declaring its class, the method is called on the instance of the derived class, and the implementation is the same. In contrast, the implementation of a virtual method can be replaced by a derived class. Keywords "Virtual" and "Override" are closely related: If the A class inherits the Class B, you can overwrite the Virtual method of the same name in the Class B in a class. You can also override a method without using the "Override" keyword, but this approach is only the purpose of the new, old method's signature and accessibility.
Wednesday, October 20, 2004
Class field initialization method:
Initialize directly in the statement statement:
Class Date {public int year = 2004; public intimonth = 10; public int iDay = 20; .......} Using constructors:
Class date {public int year, imthh, imth; public date () {// no parameter constructor = 1; im thermy = 1; iDay = 1;} .......} In order to speed up the structure based array The creating speed, the structure does not support the above two initialization structures. The structure of the C # is a major language function. Like the class, the structure can also contain other types. Since the structure is internally value type, the structure is sometimes referred to as a light version of the class. At the same time, the structure does not assume the overhead brought by the reference object, unless the exception is provided. C # structure Conclusion:
The definition of the structure is closed (cannot be used as a base class); the structure is implicitly derived from System.ValeType, and System.ValueType is a super-type (ultimate base class) of all value types. The structure has no default constructor. Preventing the creation of a class instance: a private (private) blank non-parameter constructor, such as Class CLSA {... private CLSA () {} ...} In fact, if we can deeply grasp the structure of the class The only purpose is to ensure that the members in the class can get the correct initialization, we have the understanding of various C # medium-shaped structures - it has no reason! }} ┣┣; `. ┣─┒` .. Wǒ ǒ ┟ ┟ ┟ ┍╄┓┟ ┍╄┓┟│ ╃ ╃ 人 ┝ ┝ ┣╈┤┣ ┣╈┤┣;; / ╈ ┗ ┘┗┸┛└ ┘┗┸┛└ ┛ / ┻ ┻┻: When you create a class or structure When you have to think more about the concept of equality. To be a qualified programmer, not only do you have to know how the class object and structural objects are different, assigning operations, method calls, etc., but also understand the process of new operators on class objects and structural objects. What is different. To create an instance of a class, you must use a new operator, the New operator will perform several very important processing:
Allocate memory from the pile for new objects; some constructor of that class is selected. Create an instance of a structure, also uses a New operator, the New operator will call the unique parameterless constructor of the call structure (cannot be rewritten), and the non-parameter constructor is just initializing all the fields 0 or NULL. Don't do anything else. The field is not allowed to be related to the speed of zero and the above structure. Reference Types VERSUS Value Types
The following is a reference fragment: // reference type ') Class Ref {public int x, y, cx, cy;} // value type (Because of' struct ') struct val {public int x, y, CX, cy;} static void homemethod {ref r1 = new ref (); // allocated in Heap Val v1; // allocated on stack (new optional) R1.x = 10; // Pointer Dereference v1.x = 10; // CHANGED ON Stack RectRef R2 = R1; // Copies Pointer Only RectVal V2 = V1; // Allocate On Stack & Copies Members R1.x = 20; // Changes R1 And R2 V1.x = 20; // Changes V1 , NOT V2}
Sunday, October 24, 2004
The domain access restrictions reflect the principle of encapsulation of object-oriented programming. The readonly domain cannot be written, the constant constant (const) cannot be modified, what is the difference between these two?
The read-only domain can only assign a value during initialization-declaration initialization or constructor, and other places cannot perform assignment operations for read-only domains, otherwise the compiler will report an error. A read-only domain can be an instance domain or a static domain. The type of read-only domain can be any type of C # language. However, constant constants must be assigned to the declaration, and the compiler can calculate this determined value during compilation period. Const modified constants are static variables that cannot be obtained for objects. The type of Const modified value is also limited, it can only be one of the following types (or can be converted to the following type): Sbyte, Byte, Short, USHORT, INT, UINT, Long, Ulong, Char, Float, Double, Dou, DECIMAL , BOOL, STRING, ENUM type, or reference type. The reference type capable of declaring Const can only be available for String or value NULL. In fact, if we can understand that constant constants is calculated when compiling, and substitution to each place referenced to the constant, and readonly is determined at runtime - just initialization After we don't want its value to change again, we can understand the goodness of C # designers, we can completely grasp the behavior of consT and readonly! C # does not advocate the use of the domain's protection level to public and use the user outside the class or any operation - that is too not Oo, or the specific point is too unsafe! For all the domains other than the class, C # recommends expressing attributes. Attributes do not represent storage locations, which is the foundation of attributes and domains. Inherit: An existing class (base class) When a new class (subclass) is delivered, the subclasses will automatically obtain all non-private methods, attributes, and fields that are declared in the base class (note the base class constructor is not Will be inherited.). Subclasses can expand the functionality of the base class by increasing or replacing the various methods, attributes, and fields of the inheritance. Inheritance capacity is one of the important differences between classes and structures. The structure does not support the inheritance mechanism. Learning the sea, the object-oriented programming is both a science, also an art. If this book can make everyone appreciate some of its mystery, the author is content! ! Inheritance and Precutructor Initializer, each constructor can use a preserver subclass that cannot inherit the base class constructor but can "use", specify the parent class and "this" by keyword "base". The constructor in this class is the pre-constructor of this constructor. When there is no designation, the parent class is not arrested by the default prepatructor, namely: "Base ()" access qualifier is understood: Many newcomers think that code sharing is the maximum open code, always do not think Declaring all things as "public", the less PUBLIC members inside, because you can reduce the debug, follow the principle of "to hide data. Make the class into a code black box".
Monday, October 25, 2004
One of the More Powerful Concepts in Object-Oriented Programming IS Polymorphism. The Roots of this Word, "Poly-" and "-morph" Mean, When Put Together, "Many Forms" Polymorphism (Breaky): " POLY- "A lot of intentions," - morph ", morphological shape polymorphism:
using System; public class DrawingBase {public virtual void Draw () {// the base class virtual method Console.WriteLine ( "I'm just a generic drawing object.");}} public class Line: DrawingBase {public override void Draw ( {// Sub-class rewriting the false method 1 console.writeline ("I'm a line.");}} Public class circle: Drawingbase {public override void draw () {// Sub-class rewriting false method 2 Console .Writeline ("I'm a circle.");}} Public class square: Drawingbase {public override void draw () {// Sub-class rewriting the false method 3 console.writeline ("I'm a square.") ;}}} Public class drawan (String [] args) {DrawingBase [] dobj = new drawingbase [4]; // Create a base class type array DOBJ [0] = new line (); // assignment type Convert DOBJ [1] = new circle (); // Declaration (time) is the base class, the actual type (runtime) is subclass type dobj [2] = new Square (); dobj [3] = new Drawingbase (); Foreach (DrawingBase Drawobj In Dobj) Drawobj.draw (); // Runtime "After Bind" Each DRAW version returnograph (}) AS operator is used to perform conversion between compatible types. The AS operator is used in the expressions in the following form: The Expression As Type AS operator is similar to type conversion, and the AS operator will generate empty when the conversion fails, rather than causing exceptions. Note that the AS operator only performs reference conversion and packing conversion. The AS operator cannot perform other conversions. The IS operator is used to check if the time type of the object is compatible with a given type. GetType () method and operator typeof () and system.type class
Type t = instance.gettype (); // An instance method, return a Type object type t = typeof (copy); // an operator, an operator is a type of non-aware, but also returns a TYPE object equal Sexual comparison: BOOL B = instance.gettype () == TypeOf (class); the so-called "implementation of an interface" refers to the method that the interface sounds in the interface is implemented in a certain class. The interface is essentially a definition of how the class needs to be responded. Interface Description Categories require implementation methods, properties, and events, and parameter types that each member needs to receive and returned, but leave the specific implementation of these members to implement class. Detective classes can override the virtual method and attributes in the base class, or hide the "(New keyword) of the non-virtual member in the base class. Operator Overloading :() Operators are defined for the built-in types, but that's not all You can add operators to your own types, allowing them to be used much like the operators with the built-in C # types.Requirement:. You create A Matrix Type and the Do a Mathematical Operation with Them. Solution:
Implement an add (), dotproduct (), AND Other methods to get the job done.
Matrix Result = mat1.add (mat2); // instanceormatrix results = matrix.add (mat1, mat2); // staticor Event Worsematrix Result = mat1.dotproduct (mat2) .dotproduct (mat3); // and so on .. . Much Easier to Have A Operator for the add operation and a * operator for the dot product operation.
Matrix Result = mat1 mat2; or matrix result = mat1 * mat2; or even bettermatrix results = mat1 * mat2 * mat3 * mat4;