c# 4.0 - error : is a field but used as a type -


using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.io;  namespace windowsformsapplication5 {     public class clientcontext     {         private string p;          public clientcontext(string p)         {             // todo: complete member initialization             this.p = p;         }     }      public partial class form1 : form     {         public form1()         {             initializecomponent();         }       //first construct client context, object responsible     //communication sharepoint:         private clientcontext context = new clientcontext("@url");        //then hold of list item want download, example     public list list;         public clientcontext         {            list = context.web.lists.getbytitle("001_cfr_dpv_cost_rev_sharing");         }      //note data has not been loaded yet. in order load data     //you need tell sharepoint client want download:      context.load(result, items=>items.include(         item => item["title"],         item => item["fileref"]     ));      //now data     context.executequery();      //here have list items, not content (files). download file     //you'll have this:      var item = items.first();      //get url of file want:     var fileref = item["fileref"];      //get file contents:     fileinformation fileinfo = file.openbinarydirect(context, fileref.tostring());      using (var memory = new memorystream())     {           byte[] buffer = new byte[1024 * 64];           int nread = 0;           while ((nread = fileinfo.stream.read(buffer, 0, buffer.length)) > 0)           {               memory.write(buffer, 0, nread);           }           memory.seek(0, seekorigin.begin);           // ... here have contents of file in memory,            // whatever want     }     } } 

this complete code. don't know why showing error. searched error "is field used type" , tried didn't help. please solution code since new this. thank in advance.

what trying achieve lines of code?

public partial class form1 : form {     ...     public clientcontext     {        list = context.web.lists.getbytitle("001_cfr_dpv_cost_rev_sharing");     }     } 

what public clientcontext {} inside class form1 ?

it seems intended create constructor class in class , compiler looks more property without accessors (get, set) if type or smth this.

try put get; set; accessors inside if intended create property:

public list context {         {         list = context.web.lists.getbytitle("001_cfr_dpv_cost_rev_sharing");        return list;    }  } 

or change method instead :

   public void getclientcontext()    {       list = context.web.lists.getbytitle("001_cfr_dpv_cost_rev_sharing");    } 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -