Skip to content

Instantly share code, notes, and snippets.

View ChrisMoney's full-sized avatar

Chris Weathers ChrisMoney

  • Onevested
  • St. Louis, MO
View GitHub Profile
@ChrisMoney
ChrisMoney / align_output.cs
Created February 15, 2012 12:24
C# --Code justifies and aligns a set of strings to improve the appearance of program output
/ AlignOutPut – left justify and align a set of strings to improve the appearance of program output
namespace AlignOutPut
{
using System;
class Program
{
public static void Main(string[] args)
{
string[] names = (“Christa”, “Sarah”, “Jonathan”, “Sam”, “Schmekowitz”);
@ChrisMoney
ChrisMoney / build_a_sentence.cs
Created February 15, 2012 14:27
C# --Builds A Sentence
// Build A Sentence – the following program constructs sentences by concatenating user input until the //user enters one of the termination characters
//This program shows you when you need to look for string equality the
using System;
namespace BuildASentence
{
public class Program
{
public static void Main(string[] args)
Console.WriteLine(“Each line you enter will be added to a sentence until you enter Exit or Quit”);
@ChrisMoney
ChrisMoney / bank_interest.cs
Created February 15, 2012 14:30
C# --Calculates interest on a bank account
//C# Program = Calculate Interest Table with Functions
//CalculateInterestTableWithFunctions – generate an interest table much like the other interest table //programs, but this time using reasonable divison among several functions
Namespace CalculateInterestTableWithFunctions
{
// Section 1 – input the data you will need to create the table
decimal mPrincpal = 0;
decimal mInterest = 0;
@ChrisMoney
ChrisMoney / checkRepeater.cs
Created February 15, 2012 14:32
C# --Checks a repeater for a null database object
using System;
public class Test
//Object parameter always refers to a database item
{
public static void Main()
{
checkImage(object newspic)
object
string
@ChrisMoney
ChrisMoney / checkRepeater.cs
Created February 15, 2012 14:32
C# --Checks a repeater for a null database object
using System;
public class Test
//Object parameter always refers to a database item
//newspic is a database column
{
public static void Main()
{
checkImage(object newspic)
object
string
@ChrisMoney
ChrisMoney / default_arguments.cs
Created February 15, 2012 14:35
C# --Provides variations of the same function
// Default Arguments Example
// FunctionWithDefaltArgments – provide variations of the same function, some with default //arguments, by overloading the function name
using System;
namespace FunctionsWithDefaultArguments
{
public class program
{
public static void Main(string[] args)
@ChrisMoney
ChrisMoney / functions_and_methods.cs
Created February 15, 2012 14:36
C# --Mixing functions and methods
// MixingFunctionsAndMethods – mixing class functions and object methods can class cause problems
using Systems;
namespace MixingFunctionsAndMethods
{
public class Students
{
public string sFirstName;
public string sLastName;
// InitStudent – initialize the student object
@ChrisMoney
ChrisMoney / openCSV.cs
Created February 15, 2012 14:39
C# --Opens CSV file
Open CSV file:
1. public Form1()
2. {
3. InitializeComponent();
4.
5. OpenFileDialog dialog = new OpenFileDialog();
6. dialog.Filter = "CSV Files (*.csv)|*.csv";
7. if (dialog.ShowDialog() == DialogResult.OK)
8. {
@ChrisMoney
ChrisMoney / parseInput.cs
Created February 15, 2012 14:40
C# --Parse input
// ParseSequenceWithSplit – input a series of numbers separated by commas, parse them into integers //and output the sum
namespace ParseSequenceWithSplit
{
using System;
class Program
{
public static void Main(string) args)
{
// prompt the user to input a sequence of numbers
Console.WriteLine(“Input a series of numbers separated by commas:”);
@ChrisMoney
ChrisMoney / pass_by_reference.cs
Created February 15, 2012 14:41
C# --Pass Value by Reference
// Pass By Reference
using System;
namespace PassByValue
{
public class Program
{
// Update – try to modify the values of the arguments passed to it; note that you can declare
// functions in any order in a class
public static void Update(int I, double d)