Some summary and collected materials in the process of learning C # Hope to be useful to beginners

Source: Internet
Author: User
Tags class operator

Dotnet_csharpOfSparonSummary

 

It is best for beginners to use the single-step failover method (F11) To runProgramThis helps to understand the internal operating system of the program.

 

 

Logical expression Operators...2

Normalization of positive table...2

Nested class Operator...3

Construction...3

Proxy (Commission)...4

Establish a database connection...4

 

Logical expression Operators

Operands1

Operands2

Operator

Result

Rules

True

True

&&
And
Logic and

True

One isFalseThat isFalse

True

False

False

False

True

False

False

False

False

True

True

|
Or
Logic or

True

At least one operand isTrue

True

False

True

False

True

True

False

False

False

True

True

^
XOR
Logic exclusive or

False

The two operands are the sameFalse

True

False

True

False

True

True

False

False

False

 

 

Normalization of positive table

Regular form single character type

Type

Generic form

Description

\ D

[0-9]

Any number

\ D

[^ 0-9]

Any non-numeric word

\ WS

[A-Za-z0-9 _]'

Any word character

\ W

'[^ A-Za-z0-9 _]'

Any non-single-word characters

\ S

[\ F \ n \ r \ t \ v]

Any blank characters

\ SW

[^ \ F \ n \ r \ t \ v]

Any non-blank characters

 

Character and set character

Format

Description

.

Any character except the limit line

\ P {UC}

UnicodeCharacter TypeUCAny character in

[Abcxyz]

Any delimiter in the Set

\ P {UC}

AnyUnicodeCharacter TypeUCCharacter

[^ Abcxyz]

Any character other than this delimiter

 

Characters

Format

Description

*

0Or more characters

+

1Or more characters

?

0Or1Characters

{N}

ExactlyNCharacters

{N ,}

At leastNCharacters

{N, m}

At leastNBut not many charactersMCharacters

 

Location (atomic zero degree) Statement

Format

Description

^

Start of a string or start of a new line

\ Z

The end of the string, including the delimiter.

$

The character string before or after the line.

\ G

Starting from where the last matching ended

\

Start of a string

\ B

Matching of Characters in the character field (alphanumeric and non-alphanumeric)

\ Z

End of the string before the delimiter

\ B

It is not a single-byte character.

 

 

Nested class Operator

marker

permission restriction

Public

unrestricted use of classes

protected

only this inclusion class ( containing Class ) this nested type can be used only for derived classes

private

This inclusion type has the right to allow unauthorized access to nested classes

internal

This nested type can be used only for the proxies in the same Assembly

protected internal

All agents in the same program and from this external Assembly that contains classes are this nested type can be used

 

Construction

 

 

Proxy (Commission)

Establish unicast proxy (Commission) step by step

1.Protected internalDelegateMydelegate(StringName );//Declare a proxy and specify the incoming numeric type

2.Public VoidProcessname (MydelegateMydelegateprocessname)
{
If(Name! = NULL)
// Calling the delegate:
Mydelegateprocessname (name );
}

3.Processname (New Mydelegate(Mydelegateprocessname));

4.Static Void Mydelegateprocessname (StringName)//When creating a method for processing the agent, the parameter number must be consistent with the specified type when the agent is specified.
{
Console. Writeline ("The process name is {0 }", Name );
}

 

 

 

 

 

Establish a database connection

Procedure for establishing a database connection

1.StringConnectionstring ="Integrated Security = sspi; Data Source = IP; initial catalog = databasename ;";//You can also setIntegrated Security = sspi;ChangeUid = username; Pwd = password;

2.SqlconnectionConnection =New sqlconnection(Connectionstring );//Input a database connection string to construct a database connection object

3.String sqlstr = "select * from products ";//DefinitionSQLDatabase query string

4.SqlcommandSelectcommand =New sqlcommand(Sqlstr, connection );//Construct a database connection object

5.SqldataadapterDataadapter =New sqldataadapter(Selectcommand );//Construct a database Adapter

6.Connection. Open();//Open Database

7.DatasetProductsds =New Dataset();//Define a data set

8.Dataadapter. Fill(Productsds );//UseDataadapterFill data set

9.Connection. Close();//Because data sets are used, they can be viewed offline.

 

 

Establish remote host connection

1.Private SocketSocket_c2s =New Socket(Addressfamily. InterNetwork,Sockettype. Stream,Protocoltype. TCP );//Declare a connection object

2.IPaddressMyip =IPaddress. parse("172.16. 18.1 " );//UseIPAddress StructureIPaddressObject

3.IpendpointIPE =New Ipendpoint(Myip,Convert. toint32(" 80 " ));//Passing the connection port number into the object

4.Socket_c2s.Connect(IPE );//Try to connect

5./*Accept connection, read data, send data referenceMyqqserverProgram*/

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.