Four-object-oriented-class library, delegate

Source: Internet
Author: User

VAR Universal variable:
var a = value/constructor instantiation;
Given what type of data it is, it automatically becomes the appropriate type and does not require a type conversion.

-----------------------------------------------------------------------------

Class Library:
1. A. cs source code file, sent over,
Add in your own project, reference namespaces, invoke methods;

Generally used within the company, because the source code files can be seen, and can be modified;

(This is not a class library)

Namespace consoleapplication1{    class Suanshu {//<summary>////        </summary >//        <param name= "A" > First number </param>//        <param name= "B" > Second number </param>//        < returns></returns> public        int Jiafa (int a, int b)        {            return a + b;        }        public int Jianfa (int a, int b)        {return a-a            ;        }    }
Namespace Class Library {    class program    {        static void Main (string[] args)        {            var a = ten;            var B = 20;            


Console.WriteLine (c);


}

2. Class Library Mode:
A class library, is a DLL at the end of the file, is the source code after the compilation of auxiliary files;----This file can be referenced, cannot read the modified
After you add a reference to your project, reference the corresponding namespace,
You can instantiate a common class in a class library, and you can call public methods

-----------------------------------------------------------------------------

Commissioned:
Is the agent, the event is also a delegate, but is a special delegate;
1. Declaring the delegate type:

------

public delegate int Firstdel (int a, int b)

2, the definition of the delegate variable and the assignment value:

--------

public int Jiafa (int a, int b)        {            return a + b;        }
-------
Firstdel f1 = new Fangfa (). Jiafa;            int c = f1 (5, 4);

3, the use of the delegate variable:

Namespace delegate {public    delegate int Firstdel (int a, int b);//Declare delegate type    class program    {        static void Main (Strin G[] args)        {            Firstdel f1 = new Fangfa (). Jiafa;            int c = f1 (5, 4);            Console.WriteLine (c);            Firstdel F2 = new Fangfa (). JIANFA;            c = F2 (5, 4);            Console.WriteLine (c);            c = F1 (5, 4) + F2 (5, 4);            Console.WriteLine (c);            Console.readkey ();        }    }
Namespace Delegate {    class Fangfa    {public        int Jiafa (int a, int b)        {            return a + b;        }        public int Jianfa (int a, int b)        {return a-a            ;        }

Four-object-oriented-class library, delegate

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.