DataObject.GetData 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 데이터 형식으로 데이터를 반환합니다.
오버로드
| Name | Description |
|---|---|
| GetData(String) |
문자열로 지정된 형식으로 데이터를 반환합니다. |
| GetData(Type) |
개체에 지정된 형식으로 데이터 개체를 Type 반환합니다. |
| GetData(String, Boolean) |
데이터 개체를 지정된 형식으로 반환하고 필요에 따라 데이터를 지정된 형식으로 변환합니다. |
GetData(String)
문자열로 지정된 형식으로 데이터를 반환합니다.
public:
virtual System::Object ^ GetData(System::String ^ format);
public object GetData(string format);
public object? GetData(string format);
abstract member GetData : string -> obj
override this.GetData : string -> obj
Public Function GetData (format As String) As Object
매개 변수
- format
- String
데이터의 형식을 지정하는 문자열입니다. 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.
반품
지정된 형식의 데이터를 포함하거나 null 지정된 형식으로 데이터를 사용할 수 없는 개체입니다.
구현
예외
format은 null입니다.
예제
다음 예제에서는 이 메서드를 사용하여 먼저 지정된 데이터 형식을 사용할 수 있는지(기본적으로 또는 자동 변환으로) 확인할 수 있습니다. 지정된 형식을 사용할 수 있으면 이 예제에서는 메서드를 사용하여 GetData(String) 데이터를 검색합니다.
DataObject dataObject = new DataObject("Some string data to store...");
string desiredFormat = DataFormats.UnicodeText;
byte[] data = null;
// Use the GetDataPresent method to check for the presence of a desired data format.
// This particular overload of GetDataPresent looks for both native and auto-convertible
// data formats.
if (dataObject.GetDataPresent(desiredFormat))
{
// If the desired data format is present, use one of the GetData methods to retrieve the
// data from the data object.
data = dataObject.GetData(desiredFormat) as byte[];
}
Dim dataObject As New DataObject("Some string data to store...")
Dim desiredFormat As String = DataFormats.UnicodeText
Dim data() As Byte = Nothing
' Use the GetDataPresent method to check for the presence of a desired data format.
' This particular overload of GetDataPresent looks for both native and auto-convertible
' data formats.
If dataObject.GetDataPresent(desiredFormat) Then
' If the desired data format is present, use one of the GetData methods to retrieve the
' data from the data object.
data = TryCast(dataObject.GetData(desiredFormat), Byte())
End If
다음 예제 코드에서는 먼저 메서드를 사용하여 GetDataPresent(String, Boolean) 지정된 데이터 형식을 기본적으로 사용할 수 있는지 확인합니다(자동 변환 가능한 데이터 형식이 필터링됨). 지정된 형식을 사용할 수 있는 경우 이 예제에서는 메서드를 사용하여 GetData(String) 데이터를 검색합니다.
DataObject dataObject = new DataObject("Some string data to store...");
string desiredFormat = DataFormats.UnicodeText;
bool noAutoConvert = false;
byte[] data = null;
// Use the GetDataPresent method to check for the presence of a desired data format.
// The autoconvert parameter is set to false to filter out auto-convertible data formats,
// returning true only if the specified data format is available natively.
if (dataObject.GetDataPresent(desiredFormat, noAutoConvert))
{
// If the desired data format is present, use one of the GetData methods to retrieve the
// data from the data object.
data = dataObject.GetData(desiredFormat) as byte[];
}
Dim dataObject As New DataObject("Some string data to store...")
Dim desiredFormat As String = DataFormats.UnicodeText
Dim noAutoConvert As Boolean = False
Dim data() As Byte = Nothing
' Use the GetDataPresent method to check for the presence of a desired data format.
' The autoconvert parameter is set to false to filter out auto-convertible data formats,
' returning true only if the specified data format is available natively.
If dataObject.GetDataPresent(desiredFormat, noAutoConvert) Then
' If the desired data format is present, use one of the GetData methods to retrieve the
' data from the data object.
data = TryCast(dataObject.GetData(desiredFormat), Byte())
End If
추가 정보
적용 대상
GetData(Type)
개체에 지정된 형식으로 데이터 개체를 Type 반환합니다.
public:
virtual System::Object ^ GetData(Type ^ format);
public object GetData(Type format);
public object? GetData(Type format);
abstract member GetData : Type -> obj
override this.GetData : Type -> obj
Public Function GetData (format As Type) As Object
매개 변수
- format
- Type
데이터의 형식을 지정하는 A Type 입니다. 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.
반품
지정된 형식의 데이터가 있는 데이터 개체이거나 null 지정된 형식으로 데이터를 사용할 수 없는 경우
구현
예외
format은 null입니다.
추가 정보
적용 대상
GetData(String, Boolean)
데이터 개체를 지정된 형식으로 반환하고 필요에 따라 데이터를 지정된 형식으로 변환합니다.
public:
virtual System::Object ^ GetData(System::String ^ format, bool autoConvert);
public object GetData(string format, bool autoConvert);
public object? GetData(string format, bool autoConvert);
abstract member GetData : string * bool -> obj
override this.GetData : string * bool -> obj
Public Function GetData (format As String, autoConvert As Boolean) As Object
매개 변수
- format
- String
데이터의 형식을 지정하는 문자열입니다. 미리 정의된 데이터 형식 집합은 클래스를 DataFormats 참조하세요.
- autoConvert
- Boolean
true 데이터를 지정된 형식으로 자동으로 변환하려고 시도하려면 입니다. false 데이터 형식 변환이 없습니다.
반품
지정된 형식의 데이터가 있는 데이터 개체이거나 null 지정된 형식으로 데이터를 사용할 수 없는 경우
autoConvert 매개 변수가 true 있고 데이터를 지정된 형식으로 변환할 수 없거나 자동 변환이 비활성화된 경우(매개 변수를 설정된 false상태로 호출 SetData(String, Object, Boolean)autoConvert 하여) 이 메서드는 반환합니다null.
구현
예외
format
가 null입니다.