C# Generics: 'x' is a 'type' but used like a 'variable'
For some reason, this code won't compile:
JsonSerializer serializer = new JsonSerializer();
_sectionStories = 开发者_如何学Pythonserializer.Deserialize < IDictionary<int, ObservableCollection<Story>>(new JTokenReader(contents));
The error:
Error 91 'System.Collections.Generic.IDictionary>' is a 'type' but is used like a 'variable'
What am I doing wrong here? I feel like I'm missing something basic.
Looks like a typo. I see three <
but only two >
.
You are missing a >
.
For illustrative purposes, I have matched up the <
s and >
s below:
_sectionStories = serializer.Deserialize<
IDictionary<
int,
ObservableCollection<Story>
>
>(new JTokenReader(contents)));
i think the good synthaxe is :
JsonSerializer serializer = new JsonSerializer();
_sectionStories = serializer.Deserialize < IDictionary<int, ObservableCollection<Story>>>(new JTokenReader(contents));
精彩评论