This is a refresher course for those who need to review basic knowledge of C# (csharp).


Basic Concepts edit

  • Comment styles: Single-line (//), multi-line (/* */) and XML documentation comments (///)
  • delegate (function pointers in C++): an object encapsulates reference to a method
  • HashTable: datatype allowing data retrieval by unique key
  • Interface: an approach to multiple inheritance, contains only abstract members (events, methods, properties) and no constants, data fields, constructors, and destructors
  • multicast delegate: a delegate that points to and eventually fires off several methods
  • Three-tier: presentation (UI), business (logic and underlying code) and data (from storage or other sources) layers

Basic Classes edit

  • Debug vsTrace class: debug builds only or both debug and release builds
  • Localization namespaces: System.Globalization and System.Resources
  • System.Array.CopyTo() vs System.Array.Clone(): deep vs shallow copy of an array
  • System.Text.StringBuilder over System.String: more efficient when a lot of manipulation is done to the text

Basic Limitation edit

  • System.Array: cannot store multiple data type

Basic Operations edit

  • ACID rule of thumb for transactions: Transaction must be Atomic (independent off other transactions), Consistent (committed or roll back), Isolated (other transactions cannot see intermediate results), Durable (values persist if committed)
  • ASP.NET Web application debugging: attach the aspnet_wp.exe process to the DbgClr debugger
  • Assembly deployment: MSI installer, CAB archive, and XCOPY command
  • Descending sorting: by calling Sort() and then Reverse() methods
  • Immediate window in VS.IDE: change value of a variable while debugging a C# application
  • Test cases in unit testing: Positive, negative and exception
  • try { control transfer only after finally block executed } catch (Exception ex) { } finally { executed if no exceptions but exceptions herein are not handled }

Authentication edit

  • SQL Server authentication: untrusted as username and password are not checked with the Active Directory
  • Windows Authentication: trusted as username and password are checked with the Active Directory

Database edit

  • Initial Catalog: name of wanted database in a Connection String

Accessibility Modifiers edit

  • Class inheritance: colon + base class
  • Private class-level variables: inherited but not accessible
  • Value: keyword for implicit input name of the set method in object classes
  • Protected class-level variables: available to classes in the same namespace
  • Protected internal: available to derived classes, and classes within the same Assembly, and the base class
  • Default constructor: disappears when any constructor is written
  • System.Object: top .NET class that everything is derived from
  • Method overriding: changing the method behavior for a derived class
  • Virtual method: can be over-ridden but cannot change method signature
  • Sealed class (in Java, final class): cannot be inherited
  • Sealed method: method cannot be inherited but class can when not sealed
  • Abstract class methods: not all must be abstract, some can be concrete
  • Abstract class required when at least one of the methods in the class is abstract
  • Abstract method: require non-abstract derived classes to provide their own implementation of this method
  • Interface class? an abstract class with public abstract methods all of which must be implemented in the inherited classes
  • Interface class methods: all must be abstract and public and thus accessibility modifiers not needed
  • Multiple interfaces: can be inherited
  • Namespace class: classes are declared inside a namespace

Delegates How and When edit

  • Delegate: a class -- usable if declared and instantiated
  • Delegate use: passed around as a parameter, and invoked by the receiving object
  • Delegate example 1: success = MyAddressProvider.HandleCampaign(WhatToDoWithAddresses)
  • Delegate example 2: MyMenuItem.Click += new System.Windows.RoutedEventHandlerMyMenuItem_Click)

Singleton edit