If / Else Statements:

A web programmer has different options for checking a condition and depending on the desired test will use either an "if statement" or an "if/else statement" or an "if/elseif" statement. This page gives the syntax for the "if/else statement"

for both VB.NET and C#. Review the code below and view the interactive example. 

Check 1 condition: (Determines which response to give)

A web programmer can use "if/else" statements to create a dynamic web page that displays varying results based upon the result of the statement. (An example of when to use an "if/else" statement would be if the developer wanted to display different colored text based on some condition.)

VB.NET code for the If / Else Statement:


         If something is = true then
            'give response #1
         Else
            'give response #2
         End if
            

C# code for the If / Else Statement:


       If (something is = true)
        {
         'give response #
        }
         Else
         {
         'give response #2
         } 
         




VB.NET vs. C#

Variables

Decisions

Built In Functions