Skip to content

Instantly share code, notes, and snippets.

View dnasca's full-sized avatar

Derrik dnasca

View GitHub Profile
@dnasca
dnasca / Getting and setting properties by hand.cs
Created March 17, 2015 06:39
Getting and setting properties by hand
using System;
public class Student
{
private int _id;
private string _name;
private const int PassValue = 70; //read only field
public int Id
{
@dnasca
dnasca / Serialization basics.cs
Created March 17, 2015 06:40
Serialization basics
using System;
using System.Diagnostics;
using System.Runtime.Serialization.Formatters;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
class Program
{
public static void Main()
{
@dnasca
dnasca / Static and Instance class member.cs
Created March 17, 2015 06:41
Static and Instance class member
using System;
/* Important Static and Instance class member notes
*
* !@!@ Class members = fields, methods, properties, events, indexers, constructors, !@!@
*
* Static members are invoked using the class name
* Instance members are invoked using instances(objects) of that class
*
* An instance member belongs to a specific instance(object) of a class.
@dnasca
dnasca / Types and Type Members.cs
Created March 17, 2015 06:42
Types, and Type Members
//classes, structs, enums, interfaces, delegates are Types
//Types can only have internal, or public access modifiers
public class Customer
{
//fields are type members
#region Fields
//three private fields, to encapsulate these private fields, we will make three public properties
//these private fields are Type members, more specifically, type class members
//type members can have all access modifiers (private, protected, internal, protected internal, public)
private int _id;
@dnasca
dnasca / Value Types and Reference Types.cs
Created March 17, 2015 06:42
Value Types and Reference Types
using System;
/* Differences between Value Types and Reference Types
*
* Value Types:
* All numeric data types
* Boolean, Char, and Date
* All Structures, even if the members of the struct are reference types
* Enumerations, since their underlying type is always SByte, Short, Integer, Long, Byte, UShort, UInteger, or ULong
*
@dnasca
dnasca / Why Enums.cs
Created March 17, 2015 06:43
Why Enums?
using System;
using System.Collections;
/* Enumeration Notes
*
* Enums are value types
*
* Enums are strongly-typed constants
* An explicit cast is needed to convert from enum type to an integral type and vice-versa.
* An enum of one type cannot be implicitly assigned to an enum of another type -- even though the underlying value of their members are the same
using System;
//This code isn't very practical, but it demonstrates the Child class inheriting from it's base class. Place a breakpoint at the program entry (Main()) to see the control flow.
public class Parent //this class will be inherited by class Child
{
public Parent()
{
Console.WriteLine("Parent Constructor");
}
@dnasca
dnasca / fizzbuzz.js
Last active August 29, 2015 14:18
Simply fizzbuzz -- the 'nice' looking way
/*
Write a program that prints the numbers 1 to 100. For multiples of 3, print “Fizz” instead of the number. For multiples of 5, print “Buzz”.
For numbers that are multiples of both 3 and 5 print, “FizzBuzz”
*/
for (var i = 1; i <= 100; i++) {
if (i % 15 === 0) {
console.log('FizzBuzz');
} else if (i % 3 === 0) {
@dnasca
dnasca / fizzbuzz.js
Last active August 29, 2015 14:18
my favorite fizzbuzz (so far)
/*
Write a program that prints the numbers 1 to 100. For multiples of 3, print “Fizz” instead of the number. For multiples of 5, print “Buzz”.
For numbers that are multiples of both 3 and 5 print, “FizzBuzz”
*/
for (var i = 1; i <= 100; i++) {
if (!(i % 3) && !(i % 5)) {
console.log('FizzBuzz');
@dnasca
dnasca / Topic.cs
Last active August 29, 2015 14:18
Creating a Data layer - 1a.) Data Model Classes - Starting at the top level of our 'Note'
/*
Let's start by creating the top level model.
1. Every Note has a Topic and a body.
2. Every Topic can have a Reply.
This class will represent one instance of that topic. The next class will model the Reply.
*/
using System;