FontNamesConverter.ConvertTo 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
개별 글꼴 이름이 들어 있는 문자열의 배열에서 글꼴 이름의 목록을 나타내는 문자열을 만듭니다.
public:
override System::Object ^ ConvertTo(System::ComponentModel::ITypeDescriptorContext ^ context, System::Globalization::CultureInfo ^ culture, System::Object ^ value, Type ^ destinationType);
public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType);
override this.ConvertTo : System.ComponentModel.ITypeDescriptorContext * System.Globalization.CultureInfo * obj * Type -> obj
Public Overrides Function ConvertTo (context As ITypeDescriptorContext, culture As CultureInfo, value As Object, destinationType As Type) As Object
매개 변수
- context
- ITypeDescriptorContext
형식 변환기의 컨텍스트 정보를 제공하는 ITypeDescriptorContext 개체입니다. 이 매개 변수는 이 메서드에서는 사용되지 않지만 나중에 사용하기 위해 예약되어 있습니다. 필요에 따라 이 매개 변수에 null을 전달할 수도 있습니다.
- culture
- CultureInfo
언어, 달력 체계 등과 같은 culture 정보를 나타내는 CultureInfo 개체입니다. 이 매개 변수는 이 메서드에서는 사용되지 않지만 나중에 사용하기 위해 예약되어 있습니다. 필요에 따라 이 매개 변수에 null을 전달할 수도 있습니다.
- value
- Object
변환할 문자열의 소스 배열을 나타내는 원본 개체입니다.
반환
글꼴 이름의 목록이 들어 있는 문자열을 나타내는 Object 인스턴스입니다.
예외
destinationType이 String 형식이 아닌 경우
예제
다음 코드 예제를 사용 하는 방법에 설명 합니다 ConvertTo 글꼴 이름의 목록을 포함 하는 단일 문자열을 개별 이름을 포함 하는 문자열의 배열로 변환 하는 방법입니다.
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>FontNamesConverter Example</title>
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
// Declare local variables.
System.Globalization.CultureInfo culture = new System.Globalization.CultureInfo("en");
System.ComponentModel.ITypeDescriptorContext context = null;
Object names;
Object name_string;
// Create FontNamesConverter object.
FontNamesConverter fontconverter = new FontNamesConverter();
// Create original list of fonts.
string font_list = "arial, times new roman, verdana";
// Check for type compatibility.
if (fontconverter.CanConvertFrom(context, typeof(string)))
{
// Display original string.
Label1.Text = "Original String :" + "<br /><br />" + font_list;
// Convert string to array to strings and display results.
names = fontconverter.ConvertFrom(context, culture, font_list);
Label2.Text = "Converted to Array of Strings : " + "<br /><br />";
foreach (string name_element in (string[])names)
{
Label2.Text += name_element + "<br />";
}
// Convert array of strings back to a string and display results.
name_string = fontconverter.ConvertTo(context, culture, names, typeof(string));
Label3.Text = "Converted back to String :" + "<br /><br />" + (string)name_string;
}
}
</script>
</head>
<body>
<h3>FontNamesConverter Example</h3>
<br />
<form id="form1" runat="server">
<asp:Label id="Label1" runat="server"/>
<br /><hr />
<asp:Label id="Label2" runat="server"/>
<br /><hr />
<asp:Label id="Label3" runat="server"/>
</form>
</body>
</html>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>FontNamesConverter Example</title>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
' Declare local variables.
Dim culture As New System.Globalization.CultureInfo("en")
Dim context As System.ComponentModel.ITypeDescriptorContext = Nothing
Dim names As Object
Dim name_string As Object
' Create FontNamesConverter object.
Dim fontconverter As New FontNamesConverter()
' Create original list of fonts.
Dim font_list As String = "arial, times new roman, verdana"
' Check for type compatibility.
If fontconverter.CanConvertFrom(context, GetType(String)) Then
' Display original string.
Label1.Text = "Original String :" & "<br /><br />" & font_list
' Convert string to array to strings and display results.
names = fontconverter.ConvertFrom(context, culture, font_list)
Label2.Text = "Converted to Array of Strings : " & "<br /><br />"
Dim name_element As String
For Each name_element In CType(names, String())
Label2.Text &= name_element & "<br />"
Next name_element
' Convert array of strings back to a string and display results.
name_string = fontconverter.ConvertTo(context, culture, names, _
GetType(String))
Label3.Text = "Converted back to String :" & "<br /><br />" & _
CType(name_string, String)
End If
End Sub 'Page_Load
</script>
</head>
<body>
<h3>FontNamesConverter Example</h3>
<br />
<form id="form1" runat="server">
<asp:Label id="Label1" runat="server"/>
<br /><hr />
<asp:Label id="Label2" runat="server"/>
<br /><hr />
<asp:Label id="Label3" runat="server"/>
</form>
</body>
</html>
설명
사용 하 여는 ConvertTo 메서드 이름의 목록이 포함 된 단일 문자열을 개별 글꼴 이름이 들어 있는 문자열의 배열로 변환 합니다. 문자열 "arial", "번 새 로마" 및 "verdana" 포함 된 배열을 문자열로 변환 하는 예를 들어, "arial, 새 roman, verdana 시간"입니다. 공백 없이 글꼴 이름 사이 쉼표 자동으로 삽입 되는 알 수 있습니다.
참고
이 변환기에만 변환할 수는 string 데이터 형식입니다. 합니다 destinationType 매개 변수 형식 이어야 합니다 String합니다.
참고
합니다 context 고 culture 이 버전의 메서드 매개 변수는 사용 되지 않습니다. 즉, 메서드의 이후 버전에 대 한 예약 합니다. 선택적으로 전달할 수 있습니다 null 이러한 매개 변수에 대 한 합니다.