junkone junkone - 3 months ago 48
C# Question

How can i declare list in a Json object?

I have a json object declaration in which i want to use a list of DateTime. How can i declare it? I get a error in the current definition.

public class TurtleTrade
public int Powerbars { get; set; }
public List<DateTime>() PowerbarsTime { get; set; } // Error here


As you stated the issues/Error is not because of the [JsonProperty("PowerbarsTime")] You can define List under it. The real issues is the declaration syntax of List<T>. List<DateTime>() is not a valid declaration of a List of DateTime it must be List<DateTime> So public List<DateTime>() PowerbarsTime { get; set; } should be like this :

public List<DateTime> PowerbarsTime { get; set; }