Hi all,
Im new in coding and i need to change something a code that i barely understand. And the problem is a FirstOrDefalut function.
Below is the code.
I just want to change
whitch now get the first or default categoryid among the categories that the article belongs, to get the second value, or the first among some certain values that i can give, or the first among all excluding some values that i ll give.
Im sorry if its Code is messy, or if i missed to give any info. i just dont know what i should post to help you giving me an answer.
Thank you in advance.
Im new in coding and i need to change something a code that i barely understand. And the problem is a FirstOrDefalut function.
Below is the code.
Code:
public static string GetArticlePageUrl(Article article, int categoryId) { if (categoryId < 0) { ArticleCategoryLink acl = article.ArticleCategoryLinks.FirstOrDefault(); if (acl != null && acl.Category != null) categoryId = acl.Category.ID; } if (categoryId > 0) retVal = retVal + string.Format("&cid={0}", categoryId); return retVal; }
Code:
ArticleCategoryLink acl = article.ArticleCategoryLinks.FirstOrDefault();
Im sorry if its Code is messy, or if i missed to give any info. i just dont know what i should post to help you giving me an answer.
Thank you in advance.
Comment