A1 10.1th, my motherland birthday, I began to make up my mind after the software, a pair of ferocious look, want to "Head first C #" read. During the setback plexus, the biggest mistake is to want to read this book quickly, ignoring the efficiency, finally quickly finished, just know not to do notes, understanding is not thorough, and some places even blurred. Understand: A good learning method is the greatest efficiency. rush to progress, often lead to, the results of their own can not accept, encountered problems, not to solve, will only be more tangled. Finish, in bed, before falling asleep, pick up a book to turn over "Big talk design mode", instantly I was intoxicated, a lot of vague concept can straighten out, spent a morning, some C # some concepts re-comb under, so this summary was born. This article is a lot of content from "Big talk design mode".
A2 Classes and instances
Class: Is the abstract collection of objects that have the same properties and functionality.
Instance: an instance is a real object, and instantiation is the process of creating an object, using the New keyword.
Cat cat = new Cat (); is to instantiate the cat class with new and create an instance of cat.
A3 Construction Method
Constructs a method, that is, a constructor function. Its function is to initialize the class. The constructor method has the same name as the class and does not require a return value or void.
Cat cat = new Cat (); Cat () is the constructor that initializes the cat.
Class Cat
{
private String name = "";
Public Cat (string name)
{
THIS.name = name;
}
}
A.4 Method Overloading
Method Overloading: Provides the ability to create multiple methods with the same name, but these methods require different parameter types.
Class Cat
{
private String name = "";
Public Cat (string name)
{
THIS.name = name;
}
Public Cat ()
{
THIS.name = "Nameless";
}
}
Note that when you overload a method, you must have the same method name, and the parameter type or number must be different.
Overloading can add new functionality without changing the original method.
A.5 Properties and modifiers
A property is a method or a pair of methods, but in the code that calls it, it is a field, that is, a property that is appropriate for using a method call in a field.
private int shoutnum = 3;
public int Shoutnum
{
get {return shoutnum;}
set {shoutnum = value;}
}
The get:get accessor returns the same data type as the declared property, meaning that the value or reference of the internal field can be obtained when the call is made; the set accessor does not display a setting parameter, but it has an implicit argument with the keyword value indicates that it can be used to assign values to internal fields or references when the property is called.
Summary: Variable private called field, the common called attribute.
A6 Package
The three main characteristics of object-oriented: encapsulation, inheritance, polymorphism; three commonly used modifiers: piblic private protected.
Each object contains all the information it needs to be able to operate, so the object does not rely on other objects to do its own work, which we call the encapsulation.
Dog dog = new Dog ();//Where dog () we encapsulate it, then we can call Dog (), but the outside cannot modify it.
A7 inheritance
Object inheritance represents a is-a relationship, if there are 2 objects, A and B, which can be described as B is a, then B can inherit a (dog is an animal, then the dog can inherit all the method attributes of the animal, except private).
If the subclass inherits from the parent class: (1) The subclass has properties and functions except private for the parent class. (2) subclasses have their own attributes and functions, that is, subclasses can extend the properties and functions that the parent class does not have. (3) Subclasses can also implement the functions of the parent class in their own way.
For constructors, it cannot be inherited and can only be called.
Class Dog:animal
{
}
Disadvantages of Inheritance: 1 The parent class changes, the subclass has to change. 2 inheritance destroys the wrapper, and the details of the parent class are exposed to the child class.
A8 polymorphism
Polymorphic representations of different objects can perform the same actions, but they are performed by their own implementation code.
Note Three: (1) subclasses appear as the parent class (2) subclasses are implemented in their own way when working. (3) When a subclass appears as a parent, the properties and methods that are unique to the subclass are not available.
In order for an instance of a subclass to completely replace a member from a parent class, the parent class must declare the member as virtual. Subclasses can use the Override keyword to replace the parent class implementation with its own implementation, which is overriding override.
Class Animal
{
Public virtual string Shout ()
{
}
}
Class Dog:animal
{
public override string Shout ()
{
}
}
A 9 Refactoring
Understanding is not thorough enough, next time write again.
A 10 Abstract class
C # allows classes and methods to be declared abstract, that is, abstraction classes and abstract methods.
Some points to note: (1) Abstract classes cannot be instantiated (2) abstract methods must be overridden by the quilt class. (3) If the class contains an abstract method, the class must be defined as an abstract class, whether or not other methods are included.
A 11 interface
The class that implements the interface must implement all the methods and properties in the interface
A class can support multiple interfaces, and multiple types can also support the same interface.
The interface is declared with interface, preceded by I.
interface with abstract 3 differences:
The 1 class is an abstraction of an object, an abstraction of a class, an interface as an abstraction of a behavior.
2 The interface can be used if the behavior spans different classes. For some similar classes, use the Inheritance abstract class.
3 from the design point of view, the abstract class is found from the subclass of common things, generalized out of the parent class, and then the subclass inherits the parent class, and the interface is not aware of the existence of subclasses, how the implementation of the method is not confirmed, pre-defined.
A 12 Set
Array advantages: It is continuous in memory and fast in operation.
The. NET Framework provides specialized classes of data storage and retrieval, collectively known as collections. These classes provide support for stacks, queues, lists, and hash tables.
A 13 Generics
A generic collection first requires a System.Collection.Generic namespace.
The list class is a generic equivalent class of the ArrayList class.
A 14 Events and delegates
Next time you write, it's not too thorough.
Summary : All knowledge points need to practice, and so on "first Head" read, see "pattern Design", more knock code.
A summary of the foundation of c#--physiognomy Object