title: How to programmatically assign Lag in MSProject C#
body: <p>Microsoft Docs <code>LinkPredecessors</code> Method is described as:</p>
  
  <pre><code>public void LinkPredecessors (object Tasks, Microsoft.Office.Interop.MSProject.PjTaskLinkType Link = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjFinishToStart, object Lag);
  </code></pre>
  
  <p>How can I assign a Lag value to "object Lag"?  The below code works to assign predecessor and task link type, however, I cannot figure out how to add the lag.</p>
  
  <pre><code>Microsoft.Office.Interop.MSProject.PjTaskLinkType LinkType;
  
      var p = IApp.ActiveProject;
      foreach (var y in tasksPred)
      {
          int intTaskType = Convert.ToInt32(y.RelationshipType);
  
          switch (intTaskType)
          {
              case 0:
                  LinkType = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjFinishToFinish;
                  break;
              case 1:
                  LinkType = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjFinishToStart;
                  break;
              case 2:
                  LinkType = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjStartToFinish;
                  break;
              case 3:
                  LinkType = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjStartToStart;
                  break;
              default:
                  LinkType = Microsoft.Office.Interop.MSProject.PjTaskLinkType.pjFinishToStart;
                  break;
          }
  
          if (y.UniqueIDPredecessor != "")
          {
             p.Tasks[Convert.ToInt32(y.UniqueID)].LinkPredecessors(p.Tasks[Convert.ToInt32(y.UniqueIDPredecessor)], LinkType);
          }
      }
  </code></pre>