To Lecture Notes

IT 230 -- 4/13/09

 

Review Questions

  1. How does an .aspx file tell the server that it is using C#?
    Ans: Using the tag <%@ Page Language=C# %>
     
  2. Explain these terms:
     
  3. Ans: Camel Casing: start the variable name with a lowercase letter, the first letter of each new word is uppercase. Pascal Casing: same as camel casing, but start the variable name with an uppercase letter. Hungarian Notation: Start each variable name with a three letter prefix that indicates the dataclass of the variable. Usually Hungarian notation is only used for controls in ASP.Net.
     
  4. Which of these C# variables are legal?
     

  5. What does it mean to say that C# is strongly classd?
    Ans: It means two things: that each variable must be declared as a specific dataclass link int, double, string, bool, DateTime, Random, etc. It als means that functions like int.Parse and ToString must be used to convert from one dateclass to another.
     
  6. What is wrong with these C# statements?
    Ans: It should be
  7. What is structured programming?
    Ans: Program that only uses three constructs: (1) Sequence (executing statements in order), (2) Selection (using if, if-else, or switch statements), (3) Repetition (using while or for loops).
     
  8. Explain how an if-else statement works?
    Ans: The if-else statement checks the condition of the first if statement. If the condition is true, it executes the corresponding action. If the condition is false, it goes to the next if-else statement and checks the condition. If the condition is true, it executes the corresponding action. Otherwise it continues down the line, checking each if-else statement. If it reaches an else statement at the end and none of the else-if conditions were true, it executes the action of the else.
     
  9. List as many similarities and differences between JavaScript and C# as you can.
    Ans:
    Similarities: both case sensitive, both put code in script tags, structured programming constructs are the same, class names use Pascal casing.
    Differences: C# is strongly classd; C# uses Response.Write, JS uses document.write; C# method names use Pascal casing, JS method names use camel casing; C# uses int.Parse, JS uses parseFloat; event handler headers are different; C# requires runat=server in control tags.
     
  10. Write ASP.Net code for a Literal Web control that displays the text Hello, Mr. Fred Flintstone.
    Ans:
    <asp:Literal ID=litGreeting Text=Hello, Mr. Fred Flintstone. runat=server />
    

     
  11. Write ASP.Net code for an Image Web control that displays the image fred.gif. Ans:
    <asp:Image ID=imgFred ImageURL=fred.gif runat=server />
    

     
  12. Use Visual Studio to run the Flintstones Example (Example 17).
     

 

Two C# Classes

 

More about C#

 

Web.config Files

 

Examples

 

Project Proj2