C # study notes (2)

xiaoxiao2021-03-06  57

2004/09/11 Morning Office Location Page 4.4 Calling Method Each method must have a return value, no return value, return type void, parameter optional example: double a (float n) {return n * n;} call The method is: use the necessary variables using the necessary variables to save the value of public static void main () {double d = a (3.0f); console.writeline (D);} static double a (float n) {Return N * n; // Float The result is that Double} does not create an object to call how the Static variable is delivered to the method depending on how they are numeric or reference types, if a method of variable is a numeric type representation The replication of the variable is passed to the function. The content of the reference type is transmitted is the real object itself. Any changes in the method will affect the object. There are two ways to implement the reference type REF and OUT with the REF to indicate him. The value made by the value will be long-term reserved

4.5 Handling Procedures If the program does not deal with exception returns, the program is not necessary to handle an exception in a program that occurs in the program. When the return value passed is not available, it uses them, such as the crossing of the array, and a mistake can be used to use the throw statement Out of an exception If there is an error in trying, only the Catch program is executed, if nothing happens, the user cannot skip Tyr and cannot return to the procedure from the departure

4.5.1 FinallyTry Block You can have a Finally program that is related to the FINALLY, is the exception in the Catch sentence, is executed after being executed, use Break, Continue, Return, Goto, will control the control from the program. Both are wrong,

4.5.2 Abnormal class is inheritance System.Exception, SystemException AccessException

4.5.3 Check and not check

4.6 Console I / OCONSOLE.IN Standard Enter the console.out standard Output console.Error standard error

4.6.1 The console input console.IN has two ways to enter. Return () Returns to the single character as int, if you can't find the character, return -1, readline () returns the string containing the next row, return to the NSULL4.6.2 console output console.write if you can't find the input line. Method output, WriteLine has a number of overloaded methods with wraps Write and WriteLine, which can provide different types of data 4.7 Namespace namespace provides a method of packet grouping, and related classes can be prepared in the name space. Together, you can provide assistance in some large applications, there are two ways to access these first, using a fully restricted name, second, use Using command can also use alias for bankaccount = finance.bank.accountusing insurancecount = Finance.insuranceco.account

Chapter 5 Object-Oriented Programming

5.1 Structure in the C # Structure is merely a composite data type, consisting of many other data types, composed of struct points with the keywords of Struct PUBLIC INT Y;}

Members of the constituent structure called the result of the result, also known as the domain, can access P1.x = 10; p1.x = 10; console.writeline ("{0}, {1}", P1.X, P1.Y); can be embedded in a reference Struct inner {public int A; public int b;} struct out;}, public int x;} Outer O; OIA = 3; ox = 4; 5.2 Enumeration Enumeration is a set of data types composed of named integer constants

5.3 Class class is the core OO programming of OO programming: black box development and testing, OO programming makes users access data and function in the class, access to some users can get what they want, other features Dikin in the interior Use, normal completion of these features, you can create software black boxes can be repeated

5.3.1 Constants and read-only members public class account {public readonly string sortcode;

Public Account (String code) {sortcode = code;}}}}}}}}}}} The member has its own value, his value can only be able to build once, then become a read-only 5.3.2 this reference public class point {int x; Int y; public void setx (int x) {this.x = x;}}

5.3.3 Construction Program and Destructive Function Configuration Function Table Type Type The object is usually used to initialize the following characteristics, the same name has the same name without the return value 5.3.4 Destructor Destructor There are many public class test {private int n; public test () {n = 0;} ~ test () {// tidy up}} 5.3.5 Static members belong to class, regardless of instance Whether it exists should be existing 5.4 inheritance When the class is inherited from the parent class, he also inherits the parent class member, which allows us to build and expand the current class Publci class checkaccount: account {

} C # Only single inheritance is allowed. When the user needs to inherit the interface from multiple base classes, multiple inheritance can not be achieved, can also be referenced by the ocean-based class CHECKACCOUNT S1 = New Checkaccount (); Account A1 = S1;

5.4.1 Accessing base class members can use base keywords to access the base class

5.4.2 Protected Access Protected Protected PROTECTED His Limits Access to defined classes and access to any class from which to derived 5.4.3 pairs of .NET assemblies

5.5 Object class Object class is a base class of all classes, and some methods are inherited by all types, which can provide a practical function toString () equals (); getHashcode (); gettype ();

转载请注明原文地址:https://www.9cbs.com/read-118021.html

New Post(0)