How to make an Object property of a C# class optional?
I am trying to make a class in C# in which I require the object and list properties as optional: public class Customer { [JsonProperty("Custid")] public string CustId { get; set; } [JsonProperty("CustName")] public string CustName { get; set; } } public class Store { [JsonProperty("id")] public string Id { get; set; } [JsonProperty("Name")] public string? Name { get; set; } [JsonProperty("Customer")] public List<Customer>? Customers{ get; set; } *//Error 1* [JsonProperty("OtherProperty")] public object? OtherProperty{ get; set; } *//Error 2* } The above code is giving these errors: Error 1: Th
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.