title: Set the value of custom webpart property in c#
body: <p>How to set the value of custom webpart property Programatically in C#.</p>
  
  <pre><code>SPSecurity.RunWithElevatedPrivileges(delegate()
  
   {
     using (SPSite SiteCollection = new SPSite(mySiteGuid))
  
     {
        SPWeb myWeb = SiteCollection.OpenWeb(myWebGuid);
  
        myWeb .AllowUnsafeUpdates = true;
        Microsoft.SharePoint.WebPartPages.SPLimitedWebPartManager mgr = null;
        mgr = myWeb.GetLimitedWebPartManager    ("default.aspx",System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
  
        foreach (System.Web.UI.WebControls.WebParts.WebPart myWebPart in mgr.WebParts)
          {
  
           if (myWebPart.Title == "Other Webpart Name")
            {
             myWebPart.Visible = ! myWebPart.Visible;
             myWeb.Update();
             break;
            }
          }
  }
  </code></pre>
  
  <p>});</p>
  
  <p>I have a custom property in the webpart of type string to get the input from the user.
  I wanted to updated the value of the property from c#.
  Is there any way to set the value?</p>
  
  <p>TIA</p>