Skip to content

Instantly share code, notes, and snippets.

View dnasca's full-sized avatar

Derrik dnasca

View GitHub Profile
using System;
/* //Abstract Classes//
*
* An abstract class is incomplete and CANNOT be instantiated
*
* An abstract class CAN ONLY be used as a base class
*
* An abstract class CANNOT be sealed
*
using System;
using System.Dynamic;
/* Basic Inheritance
*
* C# Supports only single class inheritance
* Multi-level class inheritance is possible
* C# supports multiple interface inheritance
* The Child class is a specialization of the base class
* Base classes are automatically instantiated before the derived classes
using System;
/* //Differences between Classes and Stucts//
*
* A Struct is a VALUE TYPE -- it is stored on the stack
*
* A Class is a REFERENCE TYPE -- it is stored on the heap
*
* VALUE TYPES hold their value in memory where they are declared
* REFERENCE TYPES hold a reference to an object in memory
@dnasca
dnasca / SimpleLittleBackupProgram.cs
Created March 17, 2015 06:07
a little console backup program
using System;
using System.IO;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Simple File Copy\n");
Console.WriteLine("Any files that have been modified in source directory within last 24 hours will be backed up.\n");
using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
/* Custom Exception Notes
*
* End the custom exception class name with 'Exception'. All .NET exceptions end with the 'Exception' suffix. eg. UserAlreadyLoggedInException
*
* If you want to provide the capability to use innerExceptions, you must overload the constructor as seen below.
@dnasca
dnasca / Default_and_Explicit_InterfaceImplementation.cs
Created March 17, 2015 06:14
Default and Explicit Interface Implementations
using System;
/* //Default and Explicit Interface Implementation//
*
* If you want to make one of the interface methods act as default -- then implement that method normally, and the other interface explicitly.
* + This will make the default method able to be accessed through a class instance
*
*/
interface I1 //default interface method implement implicitly
using System;
/* Basic Delegate Notes
*
* A delegate is a type safe function pointer. It holds a reference(pointer) to a function
*
* A delegate must have a return type
*
* The signature of the delegate MUST match the signature of the function that the delegate points to
*
@dnasca
dnasca / DelegateUsage.cs
Created March 17, 2015 06:20
fun with delegates
using System;
using System.Collections.Generic;
//the goal for this Employee class is NO HARD CODED LOGIC, we can accomplish this using delegates
public class Employee
{
public int ID { get; set; }
public string Name { get; set; }
public int CurrentSalary { get; set; }
public int YearsExperience { get; set; }
using System;
using System.IO;
//This program will read from a .txt file
/* Exception Handling Basics
*
* An exception is actually a class that derives from the System.Exception class.
* The System.Exception class provides valuable information about the exception.
* example: Message: Gets a message that describes the current exception
@dnasca
dnasca / ExceptionHandlingAbuseAndPrevention.cs
Created March 17, 2015 06:24
How to not abuse exception handling!
using System;
/* Exception Handling abuse
*
* Using exception handling to implement program logical flow is _bad_ and is termed as exception handling abuse
*
* Below are 2 examples, the first, is an example of Exception Handling Abuse
* the second, is an example of properly handling exceptions
*
*/