Object-oriented-class library, delegate, is and as operator, generic collection

Source: Internet
Author: User

Class Library:

is actually a bunch of class files, just do not see the source code of these classes, confidentiality is good.

Advantages: Good confidentiality

Cons: If this method is not good, the user cannot change it by themselves.

Most of them are DLL files. To use: Refer to Right-click, add Reference, browse, select to the appropriate DLL file, OK. Then add the "using namespace name" at the beginning

Commissioned:

A delegate can be understood as a pointer to a function.

Key words: Delegate

Declaration: public delegate int Firstdel (int a, int b);

To create a delegate variable:
Firstdel name = The same method as this delegate type;

In the class program, declare:

public delegate int Firstdel (int a, int b);

In the main function:

            Jiajian JJ = new Jiajian ();            Firstdel del = JJ. Jia;            Console.WriteLine (Del (10,20));    

IS and as operators:

is: Determine whether an object is a type

object is type name

Is this type returns TRUE, not this type returns false

As: Converts an object to a type, and if the conversion is unsuccessful, it assigns a null to the object without error.

Generic collection list<t>

Combines the benefits of collections and arrays

A set of fixed data types, not fixed lengths

Use:

Add at the beginning:

Using system.collections;using System.Collections.Generic;

In the main function:

            list<string> slist = new list<string> ();            Slist. ADD ("AAA");            Slist. ADD ("BBB");            String a = Slist[0];            list<int> ilist = new list<int> ();            IList. ADD (1);            IList. ADD (2);            list<jiajian> jlist = new list<jiajian> ();    

Universal variables:

Var

Dynamic

            var bb = "AAA";            var cc = new Random ();            var dd = new list<jiajian> ();            Dynamic EE = "AAA";            Dynamic FF = new Random ();            Dynamic GG = new list<random> ();   

Object-oriented-class library, delegate, is and as operator, generic collection

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.