S2 chapter II in-depth C # types

Source: Internet
Author: User
Tags ming

S2 Second Chapter preview notes in Depth C # data Types

Common Types java C # examples

shaping int int Age

float float float results

dual Double double- pi

self-No strings String string emergency stop address

Boolean type Whether the Boolean Boolean is a minority family

Enum type enum enum color

    1. Value type

The value type originates from systen. ValueType Family Each value-type object has a unique memory area that is used to hold its own value-value type in the region called the stack (stack) as long as it is modified in the code to be destroyed in his memory area to save this value

Example ::

Static void Main (string []age)

{

Int Heightzhang =170;// Account Height

Int Heightli = Heightzhang;// no action

Console.WriteLine ("The height of last year 's account is " +heightzhang + , Li Ming's height is +heighhtli);

Heightli =180;

Console.WriteLine ("The height of last year 's account is " +heightzhang + , Li Ming's height is +heighhtli);

}

The output of the previous string of code is:

last year The account height is the size of a, Li Ming's height is

last year The height of the account is " Li Ming's height is

Summary

For a value type, different variables allocate different storage spaces, and the storage space stores the value of the variable.

The value of the variable is passed by the assignment operation, and changing the value of one variable does not affect the value of the other variable.

The concept of encapsulation two kinds of manifestation

    1. embody enclosing methods and properties in a class as an encapsulation
    2. embody encapsulates a private field as properties of the public

Automatic Properties

public string Name (Get;set); malpractice cannot be judged by business logic

Advantages Simplified code (Reflector Anti-compilation tool artifact) private field + public get and Set

class Diagram

reflects what information is in the Class (Field properties and methods)

Packaging:

Encapsulation, also known as information hiding, refers to the manipulation of data and data using abstract data types

together to form an indivisible independent entity, hide the inner details as much as possible

Only one external interface is reserved for external exercise

value types and reference types .

Value types and reference types

Basic Types in Java 8 (value types)

Short int Long

Double float

Boolean

BYTE byte

Char character wrapper type Character

Classes Class

array int[]

String

All references to value types and reference types are present in the stack

value type Assignment principle

The True value copied on the stack

A=b

Assign the true content stored in the B variable to the variable A

value passing and reference passing

Value passing:

There is no ref with ref called reference Pass, no ref value passed

What the Ref letter can change

Value passing:  value type (does not change) Reference type ( will change )

Reference Delivery : ref value type (will change) ref Reference type (will change)

What are formal parameters and what are arguments?   A: " Span style= "font-family: Arial" > The parameter specified in the definition function is the formal parameter, and in the event of a function call, they do not account for memory cells, only the formal parameters in the function are assigned the inner deposit element when a function call occurs. At the end of the call, the memory unit that the formal parameter occupies is also freed.
 
understanding:   An argument is something that is sent to the method ~~ The line parameter is to send in the thing in the method copy processing, after processing the method returns a thing -- return value.

when the value is passed, the argument is constant ~ The parameter is changed with the calculation ~ ~ ~ When the reference is passed ~ ~ how the row parameter changes ~ How the argument will change ... .
the transfer of parameters is divided into: 1. value mode parameter pass,2. The reference method parameter is passed.

S2 chapter II in-depth C # types

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.