SPWeb web = SPContext.Current.web;
SPList list = web.Lists["yourlist"];
web.AllowUnsafeUpdate = true;
SPViewCollection viewCollection = list.Views;
string strViewName = "Custom-view(user choice)"
System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection();
//The fields that you want on the view
viewFields.Add("Type");
string query = "<where><And><IsNotNull><FieldRef Name='Name'/></IsNotNull><Eq><FieldRef Name=' Id'/><value Type='Number'>12</Value></Eq></And></where>"
viewCollection.Add(strViewName, viewFields, query, 7, true, false);
web.Update();
web.AllowUnsafeUpdates = false;This code snippet is for Creating Custom View in sharepoint site using Programatically.
Please follow the below code and implement custom view in share point list using custom code.
