C # Getting Started Classic Learning phase summary (messy)

Source: Internet
Author: User
Tags array definition case statement garbage collection object model
Clr:common language Runtime (. NET common language runtime) manages execution of all applications developed by the. NET Library

Cts:common type System (common type systems) specifies that the most basic types help to interoperate with the various languages of the. NET Framework
Cil:common Intermediate Language (Common Intermediate language) compiled code for the language, CIL code independent of the computer, OS, CPU, used by the JIT compiler to create the required native code
Jit:just in time (CIL code compiles only when needed)
Managed code: Compiles code into CIL, stores it in an assembly, compiles it to native code with the JIT compiler, and manages code that is being executed with the. NET Framework.

Create. NET application requires the following steps:
--writing application code using C #
Compile the code into CIL, stored in the assembly
Execute code, you must use the JIT compiler to compile the code into native code
--run native code in a managed CLR environment

Reset vs c#development Settings settings: Error 1: Error importing settings for "Coffeescript" [Code 5297].

Escape sequences such as \ "to escape" double quotes, with \ n is the escape sequence of newline characters
String insertion: such as output Console.WriteLine ($ "{outline}");
Operator Precedence: ++,--is used as a prefix, (), +,-unary,! , ~
*,/,%
+,-
<<,>>
<,>,<=,>=
==,!=
&
^
|
&&
||
=,*=,/=,%=,+=,-=,<<=,>>=,&=,^=,|=
+ +,--used as suffix

C # Branching techniques: Ternary operators, if statements, switch statements
The switch statement can run one case statement in C + +, but it is illegal to do so in C #, each of which requires a break to interrupt the switch execution
You can also use the return statement to not only break the switch structure, but also interrupt the execution of the current function, or you can use the goto statement
Three loops: Do loop, while loop, for loop
Cyclic interrupt command: Break,continue,return

Setting overflow check context using checked

Enumeration: Enum values are converted to other types and require an explicit conversion

Replace the function with replace ("str1", "str2"), replacing all str1 in the string with STR2
<string>. Trim () command, remove whitespace, can add char array definition delete character, test code when found trim () problem, instead trim (Mycahr), []mychar={'}

Referring to the pass parameter ref keyword, changing the parameter value of the call, you must use the variable "very const" after initialization.
Or using an out-of-parameter out keyword, you can use a variable that is not assigned, which must be considered not yet assigned when the function uses out.
The static keyword defines global variables, and const defines global constants

The signature of the function contains the name of the function and its arguments, and does not contain its return type
Delegate: A type of stored function reference, without a function body, using the delegate keyword, a delegate declaration that specifies a return type and a list of parameters

Class: Understanding for vehicle planning drawings, objects: Understanding for the car itself.
Class determines the properties and behaviors that an object will have.
Class Progrem
{//can write segments, functions, properties, constructors ...
Fields: Storing Data properties: Securing Fields Get Set (instantiated when automatic attributes are protected) function: Describes the behavior constructor of an object: Initializes the object, assigns each property of the object
}

Wisdom Podcast Basics 1:
Oop:
Packaging:
---> reduces the amount of redundant code
---> Encapsulation encapsulates a piece of hard-to-understand functionality, but provides a very simple interface for using it externally. We'll use it on OK.
Inherited:
---> Reduces redundant code in classes
---> Enables classes to have relationships with classes, laying the groundwork for polymorphism.
Characteristics:
Uniqueness: A subclass can have only one parent class
Transitivity: Grandpa kind of father kind of son
Richter conversion:
1, subclasses can be assigned to the parent class
2. If a child class object is loaded in the parent class, you can convert the parent class to the corresponding subclass object
----> Keywords
1, is: Returns the bool type, indicating whether this conversion can be done
2. As: Returns the object if the conversion succeeds, otherwise returns null
Function: We can consider all subclasses as the parent class, program for the parent class, write out the common code, and adapt to the changing needs.
Polymorphic:
---> Virtual methods
Virtual override
---> Abstract classes
Abstract override
---> Interfaces
Interface

Key words
New
1. Create objects
---> Space in the Heap (object is a reference type, the value of the reference type is in the heap)
---> Creating objects in the open heap space
Constructors for---> Calling objects
2. Hide members of the parent class (when the child class has the same function name as the parent class)
This
1. Object representing the current class
2. The display calls its own constructor
Base
1. Display the constructor of the calling parent class (not the parent class object)
2. Calling members of the parent class

Static constructors can only be executed in the following cases:
* When creating a class instance that contains a static constructor
* When accessing static members of a class that contains static constructors

String and object are simple reference types, arrays are implicit reference types, and each class created is a reference type
The compiler does not allow derived classes to be more accessible than the base class.
The specification of the interface must be placed after the base class inherits, separated by commas.
Interfaces have no keyword abstract and sealed (they do not contain implementation code, cannot be instantiated directly, and must be inheritable). Interface is not a class, so there is no inheritance System.Object

System. Object contains the method:
Equals () bool
ReferenceEquals () bool: Compares the two objects passed to it, and is not a reference to the same instance
ToString () String: Returns the string corresponding to the object instance
MemberwiseClone () object: Creates a new object instance and copies the members to replicate the object
GetType () System.Type: Returns the object type (typeof operator: You can convert the class name to a System.Type object)
GetHashCode () int: Returns a value that represents the state of an object in compressed form

constructor initializer, which places the code after the colon of the method definition. For example, you can specify the base class constructor that is used in the constructor definition of a derived class.
Specified with the base () keyword. NET instantiation process uses a constructor with the specified parameters in the base class

Define a class that cannot be created: define it as a static class, or define all its constructors as private.
Classes that cannot be created can be used by static members that they have.

For ArrayList collections, add new items using the object's Add () method;

Yield Iteration

A bin is a value type that is converted to a System.Object type, or an interface type that is implemented by a value type. Unpacking is the opposite.
Role: It allows value types to be used in a collection where the type of the item is an object, followed by an internal mechanism that allows the object method to be called on a value type.

Is operator:<operand> is <type> Note If <type> is a value type, and <operand> is the type, or if it can be disassembled into that type, true.

You cannot overload an assignment operator, such as + =, or overload && and | |

IComparable is implemented in the class of the object to compare, you can compare the object and another object: Provide CompareTo (), int, accept an object
IComparer is implemented in a separate class and can compare any two objects: Provide compare (), int, accept two objects
Class comparer provides the default implementation of the Icompare interface: Comparer.Default.Compare (one,two). CaseInsensitiveComparer class: Case insensitive

Declaration nullable type: int? Nullableint; int? is a system.nullable<int> abbreviation for easier reading

Empty merge operator?? With the null condition operator?. You can set a default value when the result is null:
Int? Count=customer.order?. Count ()?? 0;
In addition, another use of an empty condition operator is to trigger an event.

Covariance, anti-change:
The generic type parameter is defined as covariant, plus the Out keyword, and vice versa, the In keyword

Wisdom Podcast:
1. Import namespaces
A namespace is the "folder" of a class. The class is the file in the folder. Need to import namespaces
To add a reference:
If I need to access one of the classes in a project, another project
---> Add a reference to another project
---> Import namespaces

2, static, and non-static
static members: Static modifier
Instance member: not being modified by static
The member of the instance is loaded into memory before the instance member, and only if the object is created.
only static members
are called in a static class:
Static member invocation:
Class name. static member name;
Instance member invocation:
Instance name. Instance member; (instance is our object)
when to use static?
----> As a tool class, such as all extension methods! Requires static
----> resource sharing throughout the project, because it is resource-shared, so static members must wait until the end of the entire project
to be released by the resource. The
should use as few static members as possible in our project.
Inheritance is the process of creating an object.
3, design mode
----> Singleton design mode
Throughout the program, we want to ensure that the object must be unique.
Implementation:
----> First step: Privatization of Constructors
----> Second step: Declaring a static field as a globally unique singleton
----> Step three: Declaring a static function that returns a globally unique object
Example:
//First step: constructor privatization
Private Form2 ()
{
InitializeComponent ();
}

Part II: Declaring a static field to store globally unique form objects
private static Form2 _single = null;
Step three: Return a globally unique object through a static function
public static Form2 Getsingle ()
{
if (_single = = null)
{
_single = new Form2 ();
}
return _single;
}
----> Simple Factory design mode
Core: Treat all subclasses as a parent class
Practice:
Prompts the user to enter two numbers separately:
Re-enter Operator: Returns a computed parent class and invokes the method to get the result.
ADD Sub Cheng Chu
The construction industry was first applied to the concept of design patterns
1, register a company

2. Recruiting
3. Bid to buy land
4, arrange the construction team to start construction
5. Sell the building
Design patterns are designed to solve specific problems.
4. Class Library
. dll files, we use class libraries to help us encapsulate some common features
5. Value types and reference types
Value type: int double char bool decimal struct enum
Reference type: string array custom class interface delegate
Values of the value type are stored on the stack of memory, and the value of the reference type is stored in the heap.
The data stored on the stack is more efficient than the heap.

Value passing: The value type is passed as a parameter and the value itself is passed.
Attention:
Ref can change the value pass to a reference pass.
Reference passing: The value of the reference type is passed as a parameter, and the reference is passed.

6, the Learning of strings
Key Features:
Immutability, we produce a new instance in memory regardless of what we do with the string.
Resident Pool
We can treat a string as a read-only group of type char.
Gc:garbage Collection garbage collection, every once in a while, will scan the entire memory, found that if some space is not pointed. then destroy it immediately.

1. Description of the character string Immutability 2. The "Staging pool" attribute of a string constant.

String string, which can be treated as a character array, an immutable attribute (through a for loop, modifying elements in a string, failure!) )。
Property
Length//Gets the number of characters in the string. "AA I you He" →5
Method
IsNullOrEmpty () static method, judged to be null or "" (static method)
ToCharArray () converts a string to char[]
ToLower () lowercase, the return value must be received. (because: the string is immutable);
ToUpper () uppercase.
Equals () compares two strings (the state of an address/object, and = = is the same as the comparison object reference). Ignores case comparisons, stringcomparation.
For string types, both equals and equals are the values themselves.
Equals is the default comparison of addresses, but if we use equals in our own defined classes, we rewrite equals to compare them to our own requirements.
IndexOf () If no corresponding data is found, return to -1.//interview question: Count the number of occurrences of "Tiananmen" in a string.
LastIndexOf () If no corresponding data is found, return-1
Substring ()//2 overloads, truncate string.
Split ()//split string.
Join () static method
Replace ()

Object initializer: Use a non-default constructor/Do not add extra code, and provide its value for each property using a key-value pair.
Merge objects, collection initializers (for use with LINQ technology) (Compiler is the Add () method for each call collection that is provided in the collection initializer)

The var keyword, implicitly inferred variable type, can be int, string, array (numeric values are never interpreted as nullable types, unless you are defining a new int?). []) and so on
If you want to modify the value of a property in a data store object, you cannot use an anonymous type (because it is defined as a read-only property)

Dynamic keyword, variable type,

Optional parameters, parameters that do not have a default value cannot be placed after the default value parameter.

Named parameters, the parameter order is arbitrary and optional. However, if you mix named and positional parameters, you must include all positional parameters followed by named parameters.

Lambda expression: a delegate that is assigned to a variable of a delegate type; interpreted as an expression tree
Performance: argument list in parentheses =>c# statement/{multiple lines + If the delegate is not void, you need to add return}
The LINQ framework contains a generic class that can be used to encapsulate a lambda expression, and one way to use that class is to extract a lambda expression written in C # and convert it to the appropriate SQL script

The extension method, aggregate (), indicates that an accumulator function is applied to each pair of elements from the beginning to the end of the collection.

Intelligence Podcast Basics 3:
1, StringBuilder: A tool for doing a lot of string manipulation. The string object is immutable.
Convert StringBuilder to string with ToString ();
is just a tool for stitching strings, most of which are also converted to string
*stringbuilder sb=new StringBuilder ();
*SB. Append ();//Append string
*SB. ToString ();//tostring ("X2"), which represents the conversion to 16, and is two-bit.
*SB. Insert ();
*SB. Replace (); The
uses the program to stitch the TABLE:WPF in HTML without the DocumentText of the form application, and can only use Webbrow.navigatetostring (sb.). ToString ()); The
2, out:out parameter focuses on returning multiple values in the function, and the parameter must be assigned to it within the method
3, ref parameter: The ref parameter focuses on changing a value with an Australian function, and then taking out the changed value. The ref parameter does not have to be assigned within the function, and the ref parameter must be assigned a value of
4,
5, and the collection's Learning:
Non-generic collection:
ArrayList
Hashtable
Generic collection:
list<t> : Relative to an array, do not determine the initial range
Capcity: The number of elements that can be contained in the collection (initial value is 4, doubling each time)
Count: Gets the number of elements actually contained in the collection
Add (): Add a single element
AddRange (): Add a collection
Insert (): Insert an element
Insertrange (): Insert a collection
Remove (): Remove the specified element
RemoveAll (): A lambda expression, such as list. RemoveAll (n = n > 3) all data greater than 3 delete all
RemoveAt (): Remove elements from the subscript
RemoveRange (): Remove elements within a range
ToArray (): Collection Conversions to groups
ToList (): Array converted to collection

Dictionary<tkey,tvalue>
6, Boxing and unpacking:
Boxed: Value type---> Reference type
Unboxing: Reference type---> value type
We determine whether unpacking or packing has occurred, The first thing to determine is whether there is an inheritance relationship between the two data types.
What type of box to use when packing, and what type to take when dismantling.
7, encoding format:
Saves the string in the form of a binary.
ASCII
6000 GB2312
GBK GB18030

ISO
Unicode
utf-16
Utf-8
is garbled because the encoding we took when we saved the file was inconsistent with the encoding format that was taken when the file was opened.
Text file: You can still see the text file by dragging it into txt.
. txt. html. ini. XML
File Basic operation: Action file
Exist (): Determines whether the specified file exists
Create (): Create
Move (): Cut
Copy (): Copy
Delete (): Delete
ReadAllLines () ReadAllText () The default encoding format is Utf-8
Directory: Action is folder
CreateDirectory: Create a new Folder
Delete: Delete
Move: Cut
Exist () to determine if the specified folder exists
GetFiles () Gets the full path
Directory.GetFiles (@) for all files under the specified directory E:\ Download "," *.avi ") get all the. avi files
GetDirectories () Get all folders under the specified directory
can only get all folders under the current first directory
Regular expression main class: Regex
is a template that we can use to find the data we want in a lump of string.
Note: The regular expression is an action string.
Composition:
Qualifier, metacharacters, commonly used expressions
to determine whether to match: Regex.IsMatch ("string", "regular expression");
String Extraction: Regex.match ("string", "regular expression of string to extract");
(Loop fetch All): Regex.Matches ()
String substitution: Regex.Replace ("string", "regular", "replace content");
. +? Match a large number of characters
(?< name >) to match the parentheses
Greedy mode:
"1111. 11. 11. 11111. "
Greedy:. +. Match as many
non-greedy:. +?. As few matches as possible, 1

Styles: Batch settings to apply to certain properties on a control
Template: A control that sets the appearance of a control on its basis
Trigger:
To define properties for Tigger object monitoring, you should use the Trigger.property property
To define when the trigger object is activated, you should set the Trigger.value property
To define the action triggered by the trigger, set the Trigger.setters property to a collection of setter objects
Animation: Created from a storyboard, the storyboard object is contained in a resource dictionary and must be identified by the X:key property

Timeline with no keyframes: DoubleAnimation, PointAnimation, and ColorAnimation

dependency property: Enter propdp+ two tab key to insert property template

XML: Extensible Markup Language
The difference from HTML: The elements in the XML must be closed! The attributes of an element in XML must be in quotation marks
Syntax specification: Tag, nesting (Nest), attributes.
tags (i.e. element elements) to be closed, attribute values are surrounded by "", and tags can be nested with each other.
In XML, the node contains the element.
Case sensitive
To create a Xml:dom Document Object model
XmlDocument doc=new XmlDocument ();
XmlElement order = doc. documentelement;//root Node
Querying XML Using XPath:
XmlNode xn = order. selectSingleNode ("/order/items/orderitem[@Name = ' raincoat ']");
The root node does not allow deletion, that is, Doc. RemoveAll (); not allowed.
But order. RemoveAll (); Yes, move all child nodes under the root node
Delete child nodes: items.removechild (xn);
Delete the attribute value of a node: xn. Attributes.removenameditem ("Count");

Ctrl+k and s/x, shortcut keys Insert code snippet/outside code, such as #region

Delegate delegate: Use a delegate to pass a function as a parameter
A function can be assigned directly to a delegate that has the same signature as the function's signature (that is, the return value and the parameter type are the same)
Delsayhi del = sayhichinese;//new delsayhi (Sayhichinese);
Comparison: Delegates are unsafe,
The event itself is a secure delegate

To define an event:
public delegate void Deltest (); A delegate is required to register an event
public event Deltest Eventtest; No parentheses
Registering Events:
Eventtest + = new Deltest (METHOD1);
Eventtest + = new Deltest (METHOD2);
Summarize:
The role of the delegate:
placeholder, you can use a delegate variable instead of a method call (the return value of the delegate and the parameter list to determine) when you do not know the specific code of the method to be executed in the future
The role of the event:
An event acts as a delegate variable, except that there are more restrictions on functionality than on delegate variables.
For example: One, can only be bound by + = or-= To bind the method, two, only within the class call (trigger) event.

Benefits of assemblies:
Only the required assemblies are referenced in the program, reducing the size of the program;
Assemblies can encapsulate some code, providing only the necessary access interfaces.


The 16th chapter:
Cloud: Just a lot of commercialized computer hardware running in a data center that can run programs and store large amounts of data.
Resiliency, i.e. the ability to dynamically scale up (such as increasing memory and CPU) and/or dynamic scale-out (increasing the number of virtual server instances)
Cloud Service Model:
1, infrastructure as a service (IaaS): To start from the operating system is responsible for upward.
2. Platform as a service (PaaS): The value is responsible for running programs and their dependencies on the selected operating system.
3. Software as a service (SaaS): A software program or service used on a device accessed over the Internet.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.