Declaraciones En C#
Namespace
using Namespace;
Data Types
byte,sbyte,int,uint,short,ushort,long,ulong,float,double,decimal,bool,char,string,
object
VariableDeclaration
public | protected internal | protected | internal | private As
If Else
if(expression)
{
;
}
else
{
;
}
C# version of IIF()
variable == ?true:false;
Type Declaration
public |internal | private
For Loop
for(statement)
{
;
}
Suffixes
f -float, l,L - long, No double suffix, U,u - unsigned
Arrays
[] = new [ArraySize];
Initialize Array
[] = new [ArraySize]{, , ... , };
Change Size of Array
[] = new [ArraySize];
Array.Resize(ref , );
Comments
//Comment text
Multi-line comments
/* This is commented */
For Each Loop
foreach( In )
{
;[break];
[continue];
}
While Loop
w hile()
{
}
XML Comments
Press the / (forw ard slash) key 3 times.
Do-While Loop
do
{
;
} w hile ;
Line Continuation
string strtext = @“To break along string across multiple lines,
end the string, add the line continuation character
and continue the string on the next line.”;
Arithmetic Operators
+ (Addition), - (Subtraction), *(Multiplication), / (Division), % (Modulus)
String Concatenation
+
Relational Operators
< (Less Than), (Greater Than), >= (Greater Than
or Equal To), == (Equal To),! = (Not Equal To), is, as
LogicalOperators
& (And), | (Or), ^ (Xor),&& (AndAlso), || (OrElse)
Assignment Operators
= (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %=
(Modulus), &= (And),|= (OR), ^=(Exclusive OR), = (Right
Shift), ??
String Manipulation
.Substring(,[])
.Trim()
.TrimEnd([])
.TrimStart([char array])
.ToLow er()
.ToUpper()
.Replace(,)
.Equals()
.Contains()
.Join(,,[]).Compare(,,[])
.Copy()
Error Handling
try
{
//;
}
catch(Exception ex)
{
//;
}
finally
{
//
}
Select Case Statement
sw itch()
{
case :
;
;
case :
;
;
'
'
default:
;
;
}...
Regístrate para leer el documento completo.