Sunday 15 July 2012

C# Language Specification ver 5.0 and List -


I have started reading C # language specialty that comes with Visual Studio: C: \ Program Files (x86) \ Microsoft Visual Studio 11.0 \ VC # \ Specification \ 1033

In chapter 1.6.7.4 events I found the following:

An event is a member who enables to provide notifications to a class or object, an event is declared as a field, except that an event keyword in the announcement is evening And type should be a representative type.

Within a class, declaring an event member, this event behaves like a representative field type (provided that the event is not inconclusive and the accessories do not declare). The field stores the reference of the representative that represents event handlers which have been added to the event. If no event handles are present, the field is empty.

List & lt; T & gt; class declares a single event member called Chenz, which indicates that a new item has been added. Changed events are taken from the on-switch virtual method, which first checks whether the event is empty (meaning no handler is present). The idea of ​​enhancing an event is very similar to implementing representation by incident, thus there is no special language creation to increase the incidents.

The event handler is connected using the + = operator and the following example has been removed using the operator: list & lt; String & gt; .

  Adds a changed event to use the system; Class test {stable fit change; Fixed zero list changed (object sender, EventArgs e) {changeCount ++; } Fixed Zero Main () {List & lt; String & gt; Name = new list & lt; String & gt; (); Name. Changed + = new event handler (changing list); Names.Add ("Liz"); Names.Add ("Martha"); Names.Add ("Beth"); Console.WriteLine (changeCount); // Output "3"}} For advanced scenarios where the underlying storage of an event is controlled, an event announcement can clearly add and remove the addressers, Excerpts set of assets are somewhat similar.   

When I came to know about the list.Changed event, I was surprised, so I created a new console application in Visual Studio 2012 < P> When I tried to compile the application (using both the Visual Studio and Developer Command Prompt) I got the following error:

Error CS1061: 'System.Collections.Generic.List There is no definition for 'change' in and any extension method The first argument of the 'changed' type 'System.Collections.Generic.List' type can not be accepted (are you using an instruction or assembly reference?)

Am I missing something here? I used the ILSP to see the definition of the class and I do not see the changed event.

The class> list displays a normal category, which implements an incremental list of objects.

This is not related to the list code class. collection. GenericList & lt; T & gt; , except that they have the same name.

No comments:

Post a Comment