Returns the value of a DICOM element
public T GetValue<T>(Leadtools.Dicom.DicomElement element,T defaultValue)
Public Overloads Function GetValue(Of T)( _ByVal element As Leadtools.Dicom.DicomElement, _ByVal defaultValue As T _) As T
public:T^ GetValuegeneric<typename T>(Leadtools.Dicom.DicomElement^ element,T^ defaultValue)
element
an item in the data set
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.
This example will insert several elements into a DICOM data set, and then retrieve the values
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 timeMessageBox.Show(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 retrievedMessageBox.Show(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;}MessageBox.Show(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);MessageBox.Show(name);// Another overloadDateTime defaultDateTime = new DateTime();DateTime dateTime = ds.GetValue<DateTime>(null, true, DicomTag.PatientBirthDate, defaultDateTime);MessageBox.Show(dateTime.ToString());}
Imports LeadtoolsImports Leadtools.Dicom'''Private Sub DicomDataSet_GetValueExample()Dim sMsg As String' ***************************************************' *** First' *** Create some elements and set the values' ***************************************************Dim ds As DicomDataSet = 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 timeMessageBox.Show(ds.InsertElementAndSetValueResult.ToString())Dim names As String() = {"ORIGINAL", "PRIMARY"}ds.InsertElementAndSetValue(DicomTag.ImageType, names)ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, Now)ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith")' ***************************************************' *** Second' *** Retrieve the element values' ***************************************************' Get an int value of an element by specifying a tagDim highbit As Integer = ds.GetValue(Of Integer)(DicomTag.HighBit, 0)' This is how you check to see if the element value was successfully retrievedMessageBox.Show(ds.GetValueResult.ToString())' Get a list of strings value of an element by specifying a tagDim imageType As List(Of String) = ds.GetValue(Of List(Of String))(DicomTag.ImageType, Nothing)sMsg = String.Format("Result: {0}" & Constants.vbLf & "Values:", ds.GetValueResult)For Each s As String In imageTypesMsg = sMsg & Constants.vbLf & sNext sMessageBox.Show(sMsg)' Get an enumeration value of an element by specifying a tagDim p As DicomImagePhotometricInterpretationType = ds.GetValue(Of DicomImagePhotometricInterpretationType)(DicomTag.PhotometricInterpretation,DicomImagePhotometricInterpretationType.Rgb)' Get value of an element by specifying the elementDim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PatientName, False)Dim name As String = ds.GetValue(Of String)(element, Nothing)MessageBox.Show(name)' Another overloadDim defaultDateTime As DateTime = New DateTime()Dim dateTime As DateTime = ds.GetValue(Of DateTime)(Nothing, True, DicomTag.PatientBirthDate, defaultDateTime)MessageBox.Show(dateTime.ToString())End Sub
using Leadtools;using Leadtools.Dicom;using Leadtools.Examples;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 timeDebug.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 retrievedDebug.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;}Debug.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);Debug.WriteLine(name);// Another overloadDateTime defaultDateTime = new DateTime();DateTime dateTime = ds.GetValue<DateTime>(null, true, DicomTag.PatientBirthDate, defaultDateTime);Debug.WriteLine(dateTime.ToString());}
Imports LeadtoolsImports Leadtools.DicomPrivate Sub DicomDataSet_GetValueExample()Dim sMsg As String' ***************************************************' *** First' *** Create some elements and set the values' ***************************************************Dim ds As DicomDataSet = 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 timeDebug.WriteLine(ds.InsertElementAndSetValueResult.ToString())Dim names As String() = {"ORIGINAL", "PRIMARY"}ds.InsertElementAndSetValue(DicomTag.ImageType, names)ds.InsertElementAndSetValue(DicomTag.PhotometricInterpretation, DicomImagePhotometricInterpretationType.Rgb)ds.InsertElementAndSetValue(DicomTag.PatientBirthDate, System.DateTime.Now)ds.InsertElementAndSetValue(DicomTag.PatientName, "John^Smith")' ***************************************************' *** Second' *** Retrieve the element values' ***************************************************' Get an int value of an element by specifying a tagDim highbit As Integer = ds.GetValue(Of Integer)(DicomTag.HighBit, 0)' This is how you check to see if the element value was successfully retrievedDebug.WriteLine(ds.GetValueResult.ToString())' Get a list of strings value of an element by specifying a tagDim imageType As List(Of String) = ds.GetValue(Of List(Of String))(DicomTag.ImageType, Nothing)sMsg = String.Format("Result: {0}" & Constants.vbLf & "Values:", ds.GetValueResult)For Each s As String In imageTypesMsg = sMsg & Constants.vbLf & sNext sDebug.WriteLine(sMsg)' Get an enumeration value of an element by specifying a tagDim p As DicomImagePhotometricInterpretationType = ds.GetValue(Of DicomImagePhotometricInterpretationType)(DicomTag.PhotometricInterpretation,DicomImagePhotometricInterpretationType.Rgb)' Get value of an element by specifying the elementDim element As DicomElement = ds.FindFirstElement(Nothing, DicomTag.PatientName, False)Dim name As String = ds.GetValue(Of String)(element, Nothing)Debug.WriteLine(name)' Another overloadDim defaultDateTime As DateTime = New DateTime()Dim dateTime As DateTime = ds.GetValue(Of DateTime)(Nothing, True, DicomTag.PatientBirthDate, defaultDateTime)Debug.WriteLine(dateTime.ToString())End Sub
|
Products |
Support |
Feedback: GetValue<T>(DicomElement,T) Method - Leadtools.Dicom |
Introduction |
Help Version 19.0.2017.6.16
|

Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
Your email has been sent to support! Someone should be in touch! If your matter is urgent please come back into chat.
Chat Hours:
Monday - Friday, 8:30am to 6pm ET
Thank you for your feedback!
Please fill out the form again to start a new chat.
All agents are currently offline.
Chat Hours:
Monday - Friday
8:30AM - 6PM EST
To contact us please fill out this form and we will contact you via email.