I study, you supervise the Chart06

Source: Internet
Author: User

This is the change in Course 6, the original text shows some do not understand

Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;

Using static System.Console;
Using static System.Convert;

Namespace ch06ex05
{
Class Program
{
Delegate Double processdelegate (double param1, double param2);

/******

The original text is:

Static double Multiply (double param1, double param2) = param1 * PARAM2;
Static double Divide (double param1, double param2) = PARAM1/PARAM2;

Note: This compilation error VS2013

*********/

The following changes are:

Static double Multiply (double param1, double param2)
{
return param1 * PARAM2;
}
Static double Divide (double param1, double param2)
{
return param1/param2;
}

This is normal, excuse me what is the reason?

static void Main (string[] args)
{
Processdelegate process;
Console.WriteLine ("Enter 2 numbers separated with a comma:");
string input = Console.ReadLine ();
int commapos = input. IndexOf (', ');
Double param1 = convert.todouble (input. Substring (0, Commapos));
Double param2 = convert.todouble (input. Substring (Commapos + 1,
Input. LENGTH-COMMAPOS-1));
Console.WriteLine ("Enter M to multiply or D to divide:");
input = Console.ReadLine ();
if (input = = "M")
Process = new Processdelegate (Multiply);
Else
Process = new Processdelegate (Divide);
Console.WriteLine ("Result: {0}", Process (param1, param2));
Console.readkey ();
}
}
}

I study, you supervise the Chart06

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.