GetLongValue Example for C#

//This example uses the predefined variable “Text1” of type “TextBox” from “.NET Framework”.
//LEADDICOM1 is a DICOM Dataset defined outside this method
private void TestGetLongValue()
{
   int lCount = 0;
   int x = 0;
   short nRet = 0;
   LEADDICOM1.EnableMethodErrors = false;
   //move to the root element
   LEADDICOM1.MoveFirstElement(false);
   LEADDICOM1.MoveRootElement();
   //insert a new element for the Long Values
   LEADDICOM1.InsertElement(false, (int)LTDICLib.DicomDataSetTagConstants1.TAG_OFFSET_FIRST_ROOT_DIRECTORY, (short)LTDICLib.DicomVRCodeConstants.VR_UL, false, 0);
   Text1.Visible = true;
   Text1.Text = "";
   //insert some long values into the element
   LEADDICOM1.LongValueCount = 5;
   for (x = 0; x < 5; x++)
   {
      LEADDICOM1.set_LongValues(x, (int)(x * 100000));
   }
   //set the longs
   nRet = LEADDICOM1.SetLongValue(5);
   if (nRet != 0)
   {
      MessageBox.Show("Error");
      return;
   }
   LEADDICOM1.LongValueCount = 0;   //free the values
   //get the value count
   lCount = LEADDICOM1.GetValueCount();
   MessageBox.Show("There are " + System.Convert.ToString(lCount) + " values!");
   //get the values
   nRet = LEADDICOM1.GetLongValue(0, lCount);
   if (nRet == 0)
   {
      for (x = 0; x < LEADDICOM1.LongValueCount; x++)
      {
         //display each value separated by a " X "
         Text1.Text = Text1.Text + " X " + System.Convert.ToString(LEADDICOM1.get_LongValues(x));
      }
   }
   LEADDICOM1.EnableMethodErrors = true;
   MessageBox.Show("wait");
}