C#delegate delegate

Source: Internet
Author: User

Similar function, but no statement body.

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceconsoleapplication3{classProgram {Delegate DoubleProcessdelegate (DoublePARAM1,Doubleparam2); //Delegate Definition        Static DoubleMultiply (DoublePARAM1,Doubleparam2) {            returnPARAM1 *param2; }        Static DoubleDivide (DoublePARAM1,Doubleparam2) {            returnPARAM1/param2; }        Static voidMain (string[] args)            {processdelegate process; Console.WriteLine ("Enter 2 numbers separated with a comma:"); //enter two numbers, separated by commas.            stringinput =Console.ReadLine (); intCommapos = input. IndexOf (','); //gets the location where the comma character is located//get two numbers            Doubleparam1 = convert.todouble (input. Substring (0, Commapos)); Doubleparam2 = convert.todouble (input. Substring (Commapos +1, input. Length-commapos-1)); //the input m represents multiply, and d represents divideConsole.WriteLine ("Enter M to multiply or D to divide:"); Input=Console.ReadLine (); if(Input = ="M") Process=Newprocessdelegate (Multiply); ElseProcess=Newprocessdelegate (Divide); Console.WriteLine ("Result: {0}.", Process (PARAM1,PARAM2));        Console.readkey (); }    }}

C#delegate delegate

Related Article

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.