SharePoint: Create a view to filter items by Me

Following piece of code can be used to filter data by [Me].

using (SPSite site = new SPSite(""))
    using (SPWeb web = site.OpenWeb())
        char[] ViewFieldSepartors = new char[] { ';' };
        string viewFields = "LinkTitle;AssignedTo;Status;Priority;DueDate;PercentComplete";
        SPList list = web.Lists["Tasks"];
        StringCollection fields = new StringCollection();
        fields.AddRange(viewFields.Split(ViewFieldSepartors, System.StringSplitOptions.RemoveEmptyEntries));
        SPQuery query = new SPQuery();
        query.Query = "<Where><Eq><FieldRef Name='AssignedTo' /><Value Type='Integer'><UserID Type='Integer' /></Value></Eq></Where>";
        list.Views.Add("MyView", fields, query.Query, 100, true, false);

profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts