Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created February 15, 2012 14:45
Show Gist options
  • Save ChrisMoney/957e5d0d7640886cc6f3 to your computer and use it in GitHub Desktop.
Save ChrisMoney/957e5d0d7640886cc6f3 to your computer and use it in GitHub Desktop.
C# --Passing functions
C# Program:
//Passing functions
// AverageAndDisplay
using System;
namespace Example
{
public class Program
{
// access the member function
AverageAndDisplay(“grade 1”, 3.5, “grade 2”, 4.0);
// wait for user to acknowledge
Console.WriteLine(“Press Enter to ternminate…”);
Console.Read();
// AverageAndDisplay – average two numbers with their labels and display the results
public static void AverageAndDisplay(string s1, double d1, string s2, double d2)
{
double dAverage = (d1 + d2) / 2;
Console.WriteLine(The average of “ + s1 + whose value” + d1 + “and” + s2 + “whose value is” + d2 + “is” + dAverage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment