# Changing these two functions into one function

I have two functions that are similar. The only differences is that they're using two different models. How can I change them into one function?

 ITagRepository tagRepo = new TagRepository();
ICategoryRepository catRepo = new CategoryRepository();

{
var allTags = tagRepo.GetAllQueryAble();
string[] tag = tags.Split(',');

foreach (var item in tag)
{
if (allTags.Where(e => e.Name.Contains(item)).Count() == 0)
{
{
Name = item.ToString(),
LastModifiedDate = DateTime.Now,
IsDeleted = false
});
}
}
}

{
var allCategory = catRepo.GetAllQueryAble();
string[] Category = Categories.Split(',');

foreach (var item in Category)
{
if (allCategory.Where(e => e.Name.Contains(item)).Count() == 0)
{
{
Name = item.ToString(),
LastModifiedDate = DateTime.Now,
IsDeleted = false
});
}
}
}

• Why do you use ToArray in one, but not the other? Jul 24 '14 at 8:15
• Thank you for pointing that out, did not notice it Jul 24 '14 at 8:17