Please refer to the Introduction to PnP Core Component and OfficeDevPnP.Core for more details. I have created a console application and added SharePointPnPCoreOnline NuGet package for the SharePoint 2016 version.
Code Snippet
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using Microsoft.SharePoint.Client;
  8. using OfficeDevPnP.Core;
  9. namespace SP2016PnPCoreComponentDemo
  10. {
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15. // Input Parameters
  16. string siteUrl = "http://c7395723754:35298/sites/VijaiDemo";
  17. string userName = "administrator";
  18. string password = "Xy625xjCe5";
  19. string domain = "AD2012";
  20. string listTitle = "PnP Custom List";
  21. string contentTypeId = "0x0100FC6F80F7923849FBBF73F0974A2DEB9E";
  22. string contentTypeName = "PnP Content Type";
  23. OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
  24. try
  25. {
  26. // Get the client context
  27. using (var ctx = authMgr.GetNetworkCredentialAuthenticatedContext(siteUrl, userName, password, domain))
  28. {
  29. // Check if content type exists by Name/Id in the list using CSOM Extension Method
  30. List list = ctx.Web.GetListByTitle(listTitle);
  31. if (list.ContentTypeExistsByName(contentTypeName) || list.ContentTypeExistsById(contentTypeId))
  32. {
  33. Console.WriteLine("Content Type Exists");
  34. Console.ReadLine();
  35. }
  36. }
  37. }
  38. catch (Exception ex)
  39. {
  40. Console.WriteLine("Error Message: " + ex.Message);
  41. }
  42. }
  43. }
  44. }