I'm working with the SyndicationItem
class and have found the Categories
property.
According to the documentation this property doesn't have a setter, I have however found out that I can write to the property, i.e.
var syndicationItem = new SyndicationItem
{
Categories = { new SyndicationCategory("Category name") }
};
Now, that's not good enough since I can't enumerate my values like that. If I do something like this
var categoryCollection = new Collection<SyndicationCategory>();
var syndicationItem = new SyndicationItem
{
Categories = categoryCollection
};
The Categories
property get all squiggled up and tells me there's no setter.
What am I missing?
The documentation and the compiler are right - the
Categories
property doesn't have a setter.The first example you posted does not assign a new value to the
Categories
property. It gets the existing value and calls the Add method to add eachSyndicationCategory
you specify in the initializer.You will have to add categories to the existing collection: