FontNamesConverter.ConvertTo Yöntem

Tanım

Tek tek yazı tipi adları içeren bir dizi dizeden yazı tipi adlarının listesini temsil eden bir dize oluşturur.

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

Parametreler

context
ITypeDescriptorContext

Tür ITypeDescriptorContext dönüştürücüsü bağlamı hakkında bilgi sağlayan bir nesne. Bu parametre bu yöntemde kullanılmaz. Bu yöntemin gelecek sürümleri için ayrılmıştır. İsteğe bağlı olarak bu parametreyi geçirebilirsiniz null .

culture
CultureInfo

Dil CultureInfo , takvim sistemi vb. gibi bir kültürle ilgili bilgileri temsil eden nesne. Bu parametre bu yöntemde kullanılmaz. Bu yöntemin gelecek sürümleri için ayrılmıştır. İsteğe bağlı olarak bu parametreyi geçirebilirsiniz null .

value
Object

Dönüştürülecek dizelerin kaynak dizisini temsil eden nesne.

destinationType
Type

Object Dönüştürülecek veri türünü temsil eden bir örnek nesnesi. Bu parametre türünde Stringolmalıdır.

Döndürülenler

Object Yazı tipi adlarının listesini içeren bir dizeyi temsil eden örnek.

Özel durumlar

destinationType türünde Stringdeğil.

Örnekler

Aşağıdaki kod örneği, tek tek adları içeren dize dizisini yazı tipi adlarının listesini içeren tek bir dizeye dönüştürmek için yönteminin nasıl kullanılacağını ConvertTo gösterir.

<%@ 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>

Açıklamalar

ConvertTo Tek tek yazı tipi adlarını içeren dize dizisini adların listesini içeren tek bir dizeye dönüştürmek için yöntemini kullanın. Örneğin, "arial", "times new roman" ve "verdana" dizelerini içeren bir dizi "arial,times new roman,verdana" dizesine dönüşür. Virgüllerin yazı tipi adları arasına boşluk bırakmadan otomatik olarak eklendiğine dikkat edin.

Not

Bu dönüştürücü yalnızca bir string veri türüne dönüştürebilir. destinationType parametresi türünde Stringolmalıdır.

Not

context ve culture parametreleri yöntemin bu sürümünde kullanılmaz; yöntemin gelecek sürümleri için ayrılmıştır. İsteğe bağlı olarak bu parametreler için geçirebilirsiniz null .

Şunlara uygulanır

Ayrıca bkz.