There are many methods to obtain the path in C #, which are generally used in the following five ways:
// Obtain the applicationProgram.String path1 = system. Io. Directory. getcurrentdirectory ();MessageBox. Show ("Get the current working
Local type
In C #1.0, a class can only be placed in one file. In C #2.0, a keyword "partial" is used to divide a class into two parts [that is, the implementation of a class can be in multiple files]. The compilation result is exactly the same as
Anonymous Method Application and mechanism
First readCode(C #1.0 ):
1 // Here the parameter is added 2 Public Delegate Void Mydelegate ( Object Sender, eventargs E ); 3 Class Program 4 { 5 Static Void Main () 6 { 7
Demo
Use anonymous type:
Static VoidMain (){VaRSometype =New{Name ="Dancing", Age =22, Sex ="Male"}; Console. writeline (sometype );}
What will this output? Is the sometype type a fully qualified name? Not also... see the figure:
We all
Object initializer
First declare a class person:
Public ClassPerson {Public StringName {Get;Set;}Public IntAge {Get;Set;}}
Initialize it and call it:
Static VoidMain () {person=NewPerson {name ="Dancing", Age =22}; Console. writeline ("Name: {0
The database uses a local server (MySQL ):
Set global variables:
Mysqlconnection conn;Mysqldataadapter adapter;Mysqltransaction trans;
1. // database connection
Private system. Data. datatable dbconn (string strsql){String strconn = "host
Demo
StaticVoidMain () {var num =6; Var STR ="Dancing"; Var Dou =9.25d; Console. writeline (Num); console. writeline (STR); console. writeline (DOU );}
VaR keyword, used to declare and initialize local variables. The compiler deduced the actual
Starting from demo
Let's look at an example of an extension method:
1 Class Program 2 { 3 Public Static Void Main () 4 { 5 Int32 mynum = 1 ; 6 Mynum = mynum. addtooldnum ( 1 ); 7 Console. writeline (mynum ); 8 } 9
I. Prerequisites ― Program Memory Allocation The memory occupied by a C/C ++ compiled program is divided into the following parts: 1. Stack zone )―Automatically assigned and released by the compiler, storing the function parameter values and local
Pass parameters to the method by referencing:
1,OutAndRefDifferences:
If the method parameter is markedOut,Parameter can be not initialized, But the object must be assigned a value before the return;
If the method parameter is markedRef, The
Enumerative number
Enumeration is the object that cyclically accesses its associated set. It can be regarded as a movable pointer pointing to any element in the set. An enumerative number can only be associated with one set, but a set can have
1,
Packing and unpacking are an abstract concept.
2,
Packing is
Value Type Convert
Reference Type .
Reference Type Convert
Value Type
You can use the packing and unpacking functions to allow
Value Type Any value
Object Type And link the value
Normal File Download:
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> /// /// Output the file to the browser /// /// Page. Request /// Page. Response
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
///
///
Convert special Char to HTML Entity
///
///
Source string
///
Target string
Microsoft stylecop asCodeThe analysis plug-in is integrated into Visual Studio 2008 and Visual Studio 2010 to help developers quickly troubleshoot programming standards. It is of extraordinary significance to ensure the quality of software and the
Conversion between a hexadecimal string and a numeric value (C # programming guide)
The following example shows how to perform the following tasks:Returns the hexadecimal value of each character in a string.Returns the character corresponding
Use csc.exe to compile C #
ProgramYou must use the/R switch to add the referenced assembly,
1. If/R is followed by the Assembly completion path, CSC will directly locate it.
2. If/R is followed by a file name without a path, CSC searches for the
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