3

example:

public event Action<List<WKSProfile>> WorkstationProfileChanged;

I have trouble understanding the the above member. Does it imply that it returns :

Action<List<WKSProfile>>
Nik
  • 334
  • 5
  • 16
  • 1
    They indicate Generics. – Benjamin Gruenbaum Mar 27 '13 at 21:58
  • 2
    Did you look it up? This is documented in the language guide, under generics. – ssube Mar 27 '13 at 21:58
  • http://stackoverflow.com/questions/361336/what-are-generic-collections-in-c – roman m Mar 27 '13 at 21:58
  • 6
    @peachykeen - And if you never heard of generics? What would you search for? – Oded Mar 27 '13 at 21:59
  • @Oded: ["C# Types"](https://www.google.com/search?q=c%23+types), and [the second result](http://msdn.microsoft.com/en-us/library/ms173104.aspx) which mentions just this syntax. The OP seems to recognize that's where the type goes, so looking up type syntax is a great starting place. – ssube Mar 27 '13 at 22:05
  • 1
    @peachykeen - "The OP seems to recognize that's where the type goes". Where exactly? You are reading into it, methinks. – Oded Mar 27 '13 at 22:06
  • @Oded: "Does it imply that it returns..." Definitely recognizing that's where the return type goes, but unclear on whether this is one or just how the crazy works. Thus, going to the reference on (return) types. – ssube Mar 27 '13 at 22:07
  • @peachykeen - That to me seems a copy-paste of the return type of the event/delegate signature, nothing more. It doesn't mean the OP knows that what goes between the `<>` is a type. – Oded Mar 27 '13 at 22:08
  • I am trying to say here that most people do not start up knowing all the terminology or even know how to use the terminology they do know in a correct way. Questions like this are legitimate - keep the beginners in mind. – Oded Mar 27 '13 at 22:10
  • @Oded: For the sake of argument, assuming the OP is not familiar with the structure of an event, then going to the [wikipedia page for C#](http://en.wikipedia.org/wiki/C_Sharp_(programming_language)) _and searching for <_ shows similar examples in the first result, and has "generics" in bold header text, for further research. _Minimal_ research would have answered this question. – ssube Mar 27 '13 at 22:11
  • It's very possible the OP didn't know and had trouble Googling for it (turns out searching for `<` and `>` isn't too easy), but I do think they should be encouraged to try and figure it out on their own, and it turns out to be pretty easy to find some information from even non-technical sources. Not to mention that, if you are familiar with the language structure or want to follow the rabbit hole of MSDN pages, you can find a fairly detailed account. For future reference, the OP should probably check there first, just in case. – ssube Mar 27 '13 at 22:13
  • @peachykeen I had trouble googling it but point noted :) – Nik Mar 27 '13 at 22:48

1 Answers1

11

This is the syntax to specify generic type parameters.

In a generic type or method definition, a type parameters is a placeholder for a specific type that a client specifies when they instantiate a variable of the generic type. A generic class, such as GenericList<T> listed in Introduction to Generics (C# Programming Guide), cannot be used as-is because it is not really a type; it is more like a blueprint for a type. To use GenericList<T>, client code must declare and instantiate a constructed type by specifying a type argument inside the angle brackets.

Oded
  • 489,969
  • 99
  • 883
  • 1,009