0

Hi all

I've just come across this and can work out what the "Task<long?>" mean. Has anyone got an explanation or can point me to somewhere that explains it.

Thanks

andrew slaughter
  • 1,069
  • 5
  • 19
  • 34
  • 5
    Which part? The `Task` or the [`Nullable`](http://msdn.microsoft.com/en-us/library/1t3y8s4s%28v=vs.80%29.aspx)? – Patryk Ćwiek Jul 10 '13 at 08:12
  • Well, it *doesn't* mean that the programmer didn't know if the `Task` would run for a `long` time or not. ^_^; – Corak Jul 10 '13 at 08:32

3 Answers3

1

See MSDN documentation of System.Threading.Tasks.Task<TResult> :

Asynchronous operation

long? is the type parameter, which is a nullable long. It could be written as

Task<Nullable<long>>
Sam Leach
  • 12,746
  • 9
  • 45
  • 73
1

I'm not sure which part of Task<long?> you don't get, so:

Task<T> is a generic class used within Task Parallel Library to represent asynchronous operation.

long? is a shortcut for Nullable<long>: ? (nullable) operator in C#

Community
  • 1
  • 1
MarcinJuraszek
  • 124,003
  • 15
  • 196
  • 263
1

You would want to read up on Generics in the .NET Framework. Basically, generics are a way to create parametrized types. In your example there's a generic type Task<T>, which is parametrized with long?, which is a nullable long value.

Trogvar
  • 856
  • 6
  • 17