Skip to content

ASP.Net 4 Web Forms

.NET Framework

  • C# is the .NET framework language
  • A software library with a runtime environment (for execution)
    • Does memory management like java
    • Use common language runtime (CLR) to execute code

Tools:

  • IDE: Visual Studio

Csharp

HelloWorld - Console App

//main.cs
using System;

class MainClass {
  public static void Main (string[] args) {
    Console.WriteLine ("Hello World");
    Console.WriteLine ("Hello World");
     Console.ReadKey();
  }
}

Solution

  • A group of several projects (eg. Windows Forms app + Website)

Namespaces

  • Grouping of spaces that have something similar to each other
    • Java equivalent: package names?

Access Modifiers

  • private, public, protected, internal, protected internal
  • accessModifier returnType methodName (returnType param1, returnType param2){}

Static

  • static methods can only access other static methods from within the same class
  • accessModifier [optional static] returnType methodName (returnType param1, returnType param2){}

Lists

  • Declaring generic lists in C# accessModifier Lists<ClassName> listitems

For and for eachloop

for (int x=0; x<=blah; x++) {}
foreach (int blah in blahs) {}

Class

  • Keep the filename same as the class name
    • Unlike java, it's okay to have multiple classes in the same file but just don't do it for maintainability reasons.

Inheritance

  • accessModifier class classInheriting:classBeingInherited

Getters and setters{?}:

public int VariableName {
    get {return _variableName}
    set {_variableName = value}
}

Exception handling

try{}
catch{}
finally {}

Database

  • Database Engine - the system running the database (Eg. Microsoft SQL server)

Shortcuts for VS

  • Debug Continue - F5
  • Debug Step into - F11
  • Debug Step over - F10
  • Definition of object - F12
  • Back to the file - Ctrl+Left+-

Last update: August 10, 2020