For creating a list template programmatically by using server object, I'm using the SaveAsTemplate() function.
SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite oSPsite = new SPSite(strSiteURL))
{
oSPsite.AllowUnsafeUpdates = true;
using (SPWeb oSPWeb = oSPsite.OpenWeb())
{
oSPWeb.AllowUnsafeUpdates = true;
SPList list = oSPWeb.Lists[strListName];
string bkpTemplateName = "bkp" + strListName + ".stp";
list.SaveAsTemplate(bkpTemplateName, bkpTemplateName.Replace(".stp",""), "Description", true);
list.Update();
oSPWeb.AllowUnsafeUpdates = false;
}
oSPsite.AllowUnsafeUpdates = false;
}
});
But, is there a way to do the same by using CSOM?