How to check if the taxonomy group is a site collection group in SharePoint 2013

Navigate to the site collection http://c4968397007/. Click on Settings, and then click on Site Settings.Click on Term store management which is available under Site Administration section. You could be able to see all the groups in the Taxonomy Term Store. In this blog you will see how to check if the group is a site collection group in SharePoint 2013.

using System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
Microsoft.SharePoint;
using
Microsoft.SharePoint.Taxonomy;
using
System.Collections.ObjectModel;

namespace
TaxonomyCodeSamples
{
   
class Program
   
{
       
static void Main(string[] args)
       
{
           
using (SPSite site = new SPSite("http://c4968397007/"))
           
{
               
TaxonomySession taxSession =
new TaxonomySession(site);
               
//// Get the term store
               
TermStore termStore = taxSession.TermStores[
"MMS"];
               
//// Loop through all the groups in the term store
               
foreach (Group group in termStore.Groups)
               
{
                   
//// Check whether the group is a site collection group
                   
if (group.IsSiteCollectionGroup)
                   
{
                       
//// Display the name of the group
                       
Console.WriteLine(group.Name +
" is a Site Collection Group");
                       
break;
   
                }
               
}
               
Console.ReadLine();
           
}
       
}
   
}
}