public T GetValue<T>(DicomElement element,bool tree,long tag,T defaultValue)
public:T^ GetValuegeneric<typename T>(DicomElement^ element,bool tree,int64 tag,T^ defaultValue)
element
an item in the data set
tree
true to evaluate the Data Set as a tree; false to evaluate the Data Set as a list.
tag
tag of the item to find.
defaultValue
a value of type T that is returned if the actual value cannot be retrieved.
T
specifies the type of the value to return
a value of type T that is the value of the DICOM element
For information on this method, see GetValue.
using Leadtools;using Leadtools.Dicom;///private void DicomDataSet_GetValueExample(){string sMsg;// ***************************************************// *** First// *** Create some elements and set the values// ***************************************************DicomDataSet ds = new DicomDataSet();ds.InsertElementAndSetValue(DicomTag.HighBit, 15);// This is how you check to see if the element got added -- for simplicity, we only check the first timeConsole.WriteLine(ds.InsertElementAndSetValueResult.ToString());string[] names = { "ORIGINAL", "PRIMARY" };ds.InsertElementAndSetValue(DicomTag.ImageType, names);ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb);ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, DateTime.Now);ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith");// ***************************************************// *** Second// *** Retrieve the element values// ***************************************************// Get an int value of an element by specifying a tagint highbit = ds.GetValue<int>(DicomTag.HighBit, 0);// This is how you check to see if the element value was successfully retrievedConsole.WriteLine(ds.GetValueResult.ToString());// Get a list of strings value of an element by specifying a tagList<string> imageType = ds.GetValue<List<string>>(DicomTag.ImageType, null);sMsg = string.Format("Result: {0}\nValues:", ds.GetValueResult);foreach (string s in imageType){sMsg = sMsg + "\n" + s;}Console.WriteLine(sMsg);// Get an enumeration value of an element by specifying a tagDicomImagePhotometricInterpretationType p = ds.GetValue<DicomImagePhotometricInterpretationType>(DicomTag.PhotometricInterpretation,DicomImagePhotometricInterpretationType.Rgb);// Get value of an element by specifying the elementDicomElement element = ds.FindFirstElement(null, DicomTag.PatientName, false);string name = ds.GetValue<string>(element, null);Console.WriteLine(name);// Another overloadDateTime defaultDateTime = new DateTime();DateTime dateTime = ds.GetValue<DateTime>(null, true, DicomTag.PatientBirthDate, defaultDateTime);Console.WriteLine(dateTime.ToString());}
Help Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document
