DotNet Knowledge 2.5

1, commissioned: usually refers to the multicast delegate
  usually say, is a delegate container storage method pointer, function pointer is a safe, secure call for programmers. Essence is a delegate class inherits MulticastDelegate -> Delegate, IntPtr a variable of type pointer to the method of the Delegate class.

  Generally, when the parameters are passed to a method of method, use delegates.

  The delegate can be passed as a parameter, (multicast delegate) call a delegate, the method performs the N

2, ordered set
  1.Reverse () method of direct reversal ordering

  2. Bubble Sort

Copy the code
int TEMP = 0;
for (int I = 0; I <arr.length; I ++)
{
for (int I = J +. 1; J <arr.length; J ++)
{
IF (ARR [I] <ARR [ J])
{
TEMP = ARR [I];
ARR [I] = ARR [J];
ARR [J] = TEMP;
}
}
}
copy the code
3, anonymous method
    is not really no name, it will compile time CLR generating a temporary method name. After generating the anonymous method, the method pointer will be stored in a variable commission, the program calls for

4, a multicast delegate
  1. The method can be registered to a plurality of the delegate (+ =)

  2. The method can also be removed from the registered delegate (- =)

  3. If you have registered multiple return values ​​of methods delegate, delegate after the call then returns the return value of the last method

5, the event
  nature of the event is to provide a delegate object Add and Remove methods (compiling epigenetic became a private delegate object, while providing a delegate object for the add (+ =) and a remove (- =) method )

  The internal mechanism of the event is to create a private delegate object, while providing a delegate object for the add (+ =) and a remove (- =) method, the programmer only + = and - = operations

6, distinguished delegates and events
  delegates and events are not comparable, because the commission is the type of event is an object, the object is said below (event realized on commission) delegate (for standard event mode) and the difference between events.

  Internal event is entrusted to achieve, because for the event in terms of external only "registered deregister its own + = - =", the outside world can not be written off other registrants, the outside world can not take the initiative to trigger events, so if you use Delegate can not perform the above control, it gave birth to the event this syntax. Events are used to delegate instance castrated, the analogy with a custom class castration List. Events can only add, remove yourself, can not be assigned. Events can only + =, - =, not =

  Event simple to use:

Copy the code
the delegate void MyDelegate (String name);
class Program
{
static Event MyDelegate myEvent;
static void the Main (String [] args)
{
    myEvent + = new new MyDelegate (Program_myEvent);
the Console.ReadKey ();
}
static void Program_myEvent (String name )
{
    the throw new new NotImplementedException ();
}
}
copy the code
7, three-tier architecture
  What is the three-tier architecture?

    Three-tier architecture in the usual sense is to apply this business is divided into: the presentation layer (UI), business logic layer (BLL), Data Access Layer (DAL)

  The purpose of the three-tier architecture

    Thought to "high cohesion, low coupling", increased scalability items

  Specific three layers:

    Presentation Layer (UI): the popular talk is presented to the user interface, WYSIWYG see users using a system of time. For instance, we see open desktop.

    Business logic layer (BLL): specific problems for the operation, it can be said operation of the database layer, the business logic of the data processing

    Data Access Layer (DAL): The transaction layer is done directly manipulate the database, add or delete data, etc. to check for change

  The relationship between the three:

    It is a perpendicular relationship. Is a three-layer structure of the N-tier architecture, in general, between downwardly dependent level is, the lower the code before it is undetermined Interface (rules), the code can not be developed in the upper layer, the lower layer an upper layer code changes will interface the code changes together

  Three-tier architecture advantages and disadvantages:

    Advantages: clear division of labor, clear, easy to debug and maintain, and scalable

    Disadvantages: increased costs

Guess you like

Origin www.cnblogs.com/Mr-Prince/p/12104655.html