010010100101011010101101001010101001011101011010

Namespace                                                                                              If Else
using Namespace;                                                                                       if(expression)
                                                                                                       {
Data Types                                                                                                 <statement 1>;
byte,sbyte,int,uint,short,ushort,long,ulong,float,double,decimal,bool,char,string,                     }
object                                                                                                 else
                                                                                                       {
Variable Declaration                                                                                       <statement 2>;
public | protected internal | protected | internal | private <type> As                                 }
<variable_name>
                                                                                                       C# version of IIF()
Type Declaration                                                                                       variable == ?true:false;
public | internal | private <variable><suffix>
                                                                                                       For Loop
Suffixes                                                                                               for(statement)
f -float, l,L - long, No double suffix, U,u - unsigned                                                 {
                                                                                                          <statement>;
Arrays                                                                                                 }
<type>[] <name> = new <type>[ArraySize];
                                                                                                       For Each Loop
Initialize Array                                                                                       foreach(<variable> In <object>)
<type>[] <name> = new <type>[ArraySize] {<value1>, <value2>, ... , <valueN>};                          {
                                                                                                         <statements>;
Change Size of Array                                                                                     [break];
<type>[] <name> = new <type>[ArraySize];                                                                 [continue];
Array.Resize<type>(ref <name>, <size>);                                                                }
Comments                                                                                               While Loop
//Comment text                                                                                         while(<expression>)
Multi-line comments                                                                                    {
/* This is commented */                                                                                  <statement>
                                                                                                       }
XML Comments
Press the / (forward slash) key 3 times.                                                               Do-While Loop
                                                                                                       do
Line Continuation                                                                                      {
string strtext = @“To break a long string across multiple lines,                                          <statement>;
end the string, add the line continuation character                                                    } while <expression>;
and continue the string on the next line.”;
                                                                                                       Select Case Statement
Arithmetic Operators                                                                                   switch(<expression>)
+ (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus)                           {
                                                                                                          case <literal or type>:
String Concatenation                                                                                         <statement>;
+                                                                                                             <break>;
                                                                                                          case <literal or type>:
Relational Operators                                                                                         <statement>;
< (Less Than), <= (Less Than or Equal To), > (Greater Than), >= (Greater Than                                <break>;
or Equal To), == (Equal To),! = (Not Equal To), is, as                                                    '
                                                                                                          '
Logical Operators                                                                                         default:
& (And), | (Or), ^ (Xor),&& (AndAlso), || (OrElse)                                                          <statement>;
                                                                                                            <break>;
Assignment Operators                                                                                   }
= (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %=
(Modulus), &= (And),|= (OR), ^= (Exclusive OR), <<= (Left Shift), >>= (Right                           Function Structure
Shift), ??                                                                                             <private, public, protected, internal> [static] <ReturnType>
                                                                                                       <Function_Name>([Parameters])
String Manipulation                                                                                    {
.Substring(<start>,[<length>])                                                                            //body of the function;
.Trim() <trims from beginning & end of string>                                                            return <ReturnType>;
.TrimEnd([<char array>])                                                                               }
.TrimStart([char array])
.ToLower() <to lower case>                                                                             Sub Procedure Structure
.ToUpper() <to upper case>                                                                             <private, public, protected, internal> void <method_name>([Parameters])
.Replace(<find>,<replace>)                                                                             {
.Equals(<expression>) <6 available overloads>                                                              //body of the procedure;
.Contains(<string>)                                                                                    }
.Join(<seperator>,<value>,[<count>])
.Compare(<string1>,<string2>,[<ignore case>]) <7 overloads available>                                  Class Structure
.Copy(<string>)                                                                                        public class <Class_Name>
                                                                                                       {
Error Handling                                                                                            //body of class
try                                                                                                    }
{
    //<statements that may cause an error>;                                                            public
}                                                                                                      'method_prototypes
catch(Exception ex)                                                                                    'data_attributes
{                                                                                                      private
    //<statements to use when an error occurs>;                                                        'method_prototypes
}                                                                                                      'data_attributes
finally                                                                                                internal
{                                                                                                      'method_prototypes
   //<statements to use no matter what happens>                                                        static
}                                                                                                      'method_prototypes
                                                                                                       'data_attributes



                            Download More Reference Sheets & Get Programming Help @
                                         http://www.DreamInCode.net
                                                                                Edited By:PsychoCoder, Martyr2
                                                                                  Published: October 9, 2007

C# Basics Quick Reference Sheet

  • 1.
    010010100101011010101101001010101001011101011010 Namespace If Else using Namespace; if(expression) { Data Types <statement 1>; byte,sbyte,int,uint,short,ushort,long,ulong,float,double,decimal,bool,char,string, } object else { Variable Declaration <statement 2>; public | protected internal | protected | internal | private <type> As } <variable_name> C# version of IIF() Type Declaration variable == ?true:false; public | internal | private <variable><suffix> For Loop Suffixes for(statement) f -float, l,L - long, No double suffix, U,u - unsigned { <statement>; Arrays } <type>[] <name> = new <type>[ArraySize]; For Each Loop Initialize Array foreach(<variable> In <object>) <type>[] <name> = new <type>[ArraySize] {<value1>, <value2>, ... , <valueN>}; { <statements>; Change Size of Array [break]; <type>[] <name> = new <type>[ArraySize]; [continue]; Array.Resize<type>(ref <name>, <size>); } Comments While Loop //Comment text while(<expression>) Multi-line comments { /* This is commented */ <statement> } XML Comments Press the / (forward slash) key 3 times. Do-While Loop do Line Continuation { string strtext = @“To break a long string across multiple lines, <statement>; end the string, add the line continuation character } while <expression>; and continue the string on the next line.”; Select Case Statement Arithmetic Operators switch(<expression>) + (Addition), - (Subtraction), * (Multiplication), / (Division), % (Modulus) { case <literal or type>: String Concatenation <statement>; + <break>; case <literal or type>: Relational Operators <statement>; < (Less Than), <= (Less Than or Equal To), > (Greater Than), >= (Greater Than <break>; or Equal To), == (Equal To),! = (Not Equal To), is, as ' ' Logical Operators default: & (And), | (Or), ^ (Xor),&& (AndAlso), || (OrElse) <statement>; <break>; Assignment Operators } = (Equals), += (Addition), -= (Subtraction), *= (Multiplication), /= (Division), %= (Modulus), &= (And),|= (OR), ^= (Exclusive OR), <<= (Left Shift), >>= (Right Function Structure Shift), ?? <private, public, protected, internal> [static] <ReturnType> <Function_Name>([Parameters]) String Manipulation { .Substring(<start>,[<length>]) //body of the function; .Trim() <trims from beginning & end of string> return <ReturnType>; .TrimEnd([<char array>]) } .TrimStart([char array]) .ToLower() <to lower case> Sub Procedure Structure .ToUpper() <to upper case> <private, public, protected, internal> void <method_name>([Parameters]) .Replace(<find>,<replace>) { .Equals(<expression>) <6 available overloads> //body of the procedure; .Contains(<string>) } .Join(<seperator>,<value>,[<count>]) .Compare(<string1>,<string2>,[<ignore case>]) <7 overloads available> Class Structure .Copy(<string>) public class <Class_Name> { Error Handling //body of class try } { //<statements that may cause an error>; public } 'method_prototypes catch(Exception ex) 'data_attributes { private //<statements to use when an error occurs>; 'method_prototypes } 'data_attributes finally internal { 'method_prototypes //<statements to use no matter what happens> static } 'method_prototypes 'data_attributes Download More Reference Sheets & Get Programming Help @ http://www.DreamInCode.net Edited By:PsychoCoder, Martyr2 Published: October 9, 2007