I have the following class in my model:
public class Notebook : TableServiceEntity
{
public string NotebookLinksJSON { get; set; }
public string NotebookLinksCount {
get {
var a = NotebookLinksJSON.FromJSONString<Notebook.Link>().Details;
var b = a.Count();
return NotebookLinksJSON.FromJSONString<Notebook.Link>().Details.Count();
}
}
public class Link
{
public Link() {
_details = new List<Detail>();
}
public IList<Detail> Details {
get { return _details; }
}
private List<Detail> _details = new List<Detail>();
public class Detail
{
public string L { get; set; }
public string R { get; set; }
}
}
}
What I want is to have a property NotebookLinksCount that will return the number of details in the NotebookLinksJSON string.
The datatypes of the vars are as follows:
var a = NotebookLinksJSON.FromJSONString<Notebook.Link>().Details;
var b = a.Count();
a is an interface System.Collections.Generic.IList<T>
b is ?? <<< nothing shows when I try to find out what type it is
When I build I get the following error:
Error 3 Non-invocable member
'System.Collections.Generic.ICollection<S.Storage.Models.Notebook.Link.Detail>.Count'
cannot be used like a method.
Can someone help me with some advice as to how I can get the count of NotebookLinks? Also if NotebookLinksJSON is a null then I would like the count to return a zero.
Countis a property. Remove the()and call it like:Edit:
Answering a question from @Melissa in the comments: To make it return null in the event that the
NotebookLinksJSONobject is null, you need a null check.And I recommend changing your NotebookLinksCount property to return an int. Though if you really need a string, you can change it to be that.