Share via


XmlConvert.ToString Yöntem

Tanım

Kesin olarak yazılan verileri eşdeğer String bir gösterime dönüştürür.

Aşırı Yüklemeler

ToString(Single)

öğesini Single değerine Stringdönüştürür.

ToString(TimeSpan)

öğesini TimeSpan değerine Stringdönüştürür.

ToString(UInt16)

öğesini UInt16 değerine Stringdönüştürür.

ToString(UInt32)

öğesini UInt32 değerine Stringdönüştürür.

ToString(DateTimeOffset, String)

Sağlanan DateTimeOffset öğesini belirtilen biçimde değerine String dönüştürür.

ToString(DateTime, String)

öğesini DateTime değerine Stringdönüştürür.

ToString(DateTime, XmlDateTimeSerializationMode)

DateTime belirtilen öğesini kullanarak XmlDateTimeSerializationMode öğesini öğesine String dönüştürür.

ToString(SByte)

öğesini SByte değerine Stringdönüştürür.

ToString(UInt64)

öğesini UInt64 değerine Stringdönüştürür.

ToString(Int64)

öğesini Int64 değerine Stringdönüştürür.

ToString(Boolean)

öğesini Boolean değerine Stringdönüştürür.

ToString(Int16)

öğesini Int16 değerine Stringdönüştürür.

ToString(Guid)

öğesini Guid değerine Stringdönüştürür.

ToString(Double)

öğesini Double değerine Stringdönüştürür.

ToString(Decimal)

öğesini Decimal değerine Stringdönüştürür.

ToString(DateTimeOffset)

Sağlanan DateTimeOffset öğesini öğesine Stringdönüştürür.

ToString(DateTime)
Geçersiz.
Geçersiz.

öğesini DateTime değerine Stringdönüştürür.

ToString(Char)

öğesini Char değerine Stringdönüştürür.

ToString(Byte)

öğesini Byte değerine Stringdönüştürür.

ToString(Int32)

öğesini Int32 değerine Stringdönüştürür.

ToString(Single)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Single değerine Stringdönüştürür.

public:
 static System::String ^ ToString(float value);
public static string ToString (float value);
static member ToString : single -> string
Public Shared Function ToString (value As Single) As String

Parametreler

value
Single

Dönüştürülecek değer.

Döndürülenler

öğesinin Singledize gösterimi.

Açıklamalar

value Single.PositiveInfinity veya Single.NegativeInfinity ise, bu yöntem sırasıyla INF veya -INF dizesini döndürür.

Ayrıca bkz.

Şunlara uygulanır

ToString(TimeSpan)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini TimeSpan değerine Stringdönüştürür.

public:
 static System::String ^ ToString(TimeSpan value);
public static string ToString (TimeSpan value);
static member ToString : TimeSpan -> string
Public Shared Function ToString (value As TimeSpan) As String

Parametreler

value
TimeSpan

Dönüştürülecek değer.

Döndürülenler

öğesinin TimeSpandize gösterimi.

Şunlara uygulanır

ToString(UInt16)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Önemli

Bu API, CLS uyumlu değildir.

öğesini UInt16 değerine Stringdönüştürür.

public:
 static System::String ^ ToString(System::UInt16 value);
[System.CLSCompliant(false)]
public static string ToString (ushort value);
[<System.CLSCompliant(false)>]
static member ToString : uint16 -> string
Public Shared Function ToString (value As UShort) As String

Parametreler

value
UInt16

Dönüştürülecek değer.

Döndürülenler

öğesinin UInt16dize gösterimi.

Öznitelikler

Şunlara uygulanır

ToString(UInt32)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Önemli

Bu API, CLS uyumlu değildir.

öğesini UInt32 değerine Stringdönüştürür.

public:
 static System::String ^ ToString(System::UInt32 value);
[System.CLSCompliant(false)]
public static string ToString (uint value);
[<System.CLSCompliant(false)>]
static member ToString : uint32 -> string
Public Shared Function ToString (value As UInteger) As String

Parametreler

value
UInt32

Dönüştürülecek değer.

Döndürülenler

öğesinin UInt32dize gösterimi.

Öznitelikler

Şunlara uygulanır

ToString(DateTimeOffset, String)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Sağlanan DateTimeOffset öğesini belirtilen biçimde değerine String dönüştürür.

public:
 static System::String ^ ToString(DateTimeOffset value, System::String ^ format);
public static string ToString (DateTimeOffset value, string format);
static member ToString : DateTimeOffset * string -> string
Public Shared Function ToString (value As DateTimeOffset, format As String) As String

Parametreler

value
DateTimeOffset

DateTimeOffset dönüştürülecek.

format
String

Dönüştürülen s biçim. format parametresi, XML dateTime türü için W3C Önerisi'nin herhangi bir alt kümesi olabilir. (Daha fazla bilgi için XML Şeması belirtiminin dateTime bölümüne bakın..)

Döndürülenler

String Sağlanan DateTimeOffsetöğesinin belirtilen biçiminde bir gösterim.

Örnekler

Aşağıdaki örnek, geçerli saatin gösterimini DateTimeOffset belirtilen biçimde bire String dönüştürür.

using System;
using System.Xml;

class Example
{
    static void Main()
    {
        // Create the DateTimeOffset object and set the time to the current time.
        DateTimeOffset dto;
        dto = DateTimeOffset.Now;

        // Convert the DateTimeObject to a string in a specified format and display the result.
        // The specified format must be a subset of the W3C Recommendation for the XML dateTime type.
        String timeAsString = XmlConvert.ToString(dto, "yyyy-MM-ddTHH:mm:sszzzzzzz");
        Console.WriteLine(timeAsString);
    }
}
Imports System.Xml

Module Module1
    Sub Main()

        ' Create the DateTimeOffset object and set the time to the current time.
        Dim dto As DateTimeOffset
        dto = DateTimeOffset.Now

        ' Convert the DateTimeObject to a string in a specified format and display the result.
        ' The specified format must be a subset of the W3C Recommendation for the XML dateTime type.
        Dim timeAsString As [String] = XmlConvert.ToString(dto, "yyyy-MM-ddTHH:mm:sszzzzzzz")
        Console.WriteLine(timeAsString)

    End Sub
End Module

Şunlara uygulanır

ToString(DateTime, String)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini DateTime değerine Stringdönüştürür.

public:
 static System::String ^ ToString(DateTime value, System::String ^ format);
public static string ToString (DateTime value, string format);
static member ToString : DateTime * string -> string
Public Shared Function ToString (value As DateTime, format As String) As String

Parametreler

value
DateTime

Dönüştürülecek değer.

format
String

Dönüştürülen dizenin nasıl görüntüleneceğini tanımlayan biçim yapısı. Geçerli biçimler şunlardır: "yyyy-MM-ddTHH:mm:sszzzzz" ve alt kümeleri.

Döndürülenler

belirtilen biçimde öğesinin DateTime dize gösterimi.

Örnekler

Aşağıdaki örnek, veri türlerini dizeye dönüştürür ve ardından bilgileri konsola yazar.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   //Define the order data.  They will be converted to string 
   //before being written out.
   Int16 custID = 32632;
   String^ orderID = "367A54";
   DateTime orderDate = DateTime::Now;
   Double price = 19.95;
   
   //Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;
   
   //Write an element (this one is the root)
   writer->WriteStartElement( "order" );
   
   //Write the order date.
   writer->WriteAttributeString( "date", XmlConvert::ToString( orderDate, "yyyy-MM-dd" ) );
   
   //Write the order time.
   writer->WriteAttributeString( "time", XmlConvert::ToString( orderDate, "HH:mm:ss" ) );
   
   //Write the order data.
   writer->WriteElementString( "orderID", orderID );
   writer->WriteElementString( "custID", XmlConvert::ToString( custID ) );
   writer->WriteElementString( "price", XmlConvert::ToString( price ) );
   
   //Write the close tag for the root element
   writer->WriteEndElement();
   
   //Write the XML and close the writer
   writer->Close();
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    //Define the order data.  They will be converted to string
    //before being written out.
    Int16 custID = 32632;
    String orderID = "367A54";
    DateTime orderDate = new DateTime();
    orderDate = DateTime.Now;
    Double price = 19.95;

    //Create a writer that outputs to the console.
    XmlTextWriter writer = new XmlTextWriter (Console.Out);
    writer.Formatting = Formatting.Indented;

    //Write an element (this one is the root)
    writer.WriteStartElement("order");

    //Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"));

    //Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"));

    //Write the order data.
    writer.WriteElementString("orderID", orderID);
    writer.WriteElementString("custID", XmlConvert.ToString(custID));
    writer.WriteElementString("price", XmlConvert.ToString(price));

    //Write the close tag for the root element
    writer.WriteEndElement();

    //Write the XML and close the writer
    writer.Close();
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    'Define the order data.  They will be converted to string
    'before being written out.
    Dim custID as Int16 = 32632
    Dim orderID as String = "367A54"
    Dim orderDate as DateTime 
    orderDate = DateTime.Now
    Dim price as Double = 19.95

    'Create a writer that outputs to the console.
    Dim writer as XmlTextWriter = new XmlTextWriter (Console.Out)
    'Use indenting for readability
    writer.Formatting = Formatting.Indented
    
    'Write an element (this one is the root)
    writer.WriteStartElement("order")

    'Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"))

    'Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"))
    
    'Write the order data.
    writer.WriteElementString("orderID", orderID)
    writer.WriteElementString("custID", XmlConvert.ToString(custID))
    writer.WriteElementString("price", XmlConvert.ToString(price))

    'Write the close tag for the root element
    writer.WriteEndElement()
             

    'Write the XML and close the writer
    writer.Flush()
    writer.Close()  

  end sub
end class

Şunlara uygulanır

ToString(DateTime, XmlDateTimeSerializationMode)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

DateTime belirtilen öğesini kullanarak XmlDateTimeSerializationMode öğesini öğesine String dönüştürür.

public:
 static System::String ^ ToString(DateTime value, System::Xml::XmlDateTimeSerializationMode dateTimeOption);
public static string ToString (DateTime value, System.Xml.XmlDateTimeSerializationMode dateTimeOption);
static member ToString : DateTime * System.Xml.XmlDateTimeSerializationMode -> string
Public Shared Function ToString (value As DateTime, dateTimeOption As XmlDateTimeSerializationMode) As String

Parametreler

value
DateTime

Dönüştürülecek DateTime değer.

dateTimeOption
XmlDateTimeSerializationMode

Değerin XmlDateTimeSerializationMode nasıl işleneceğini DateTime belirten değerlerden biri.

Döndürülenler

eşdeğeridir StringDateTime.

Özel durumlar

Değer dateTimeOption geçerli değil.

value veya dateTimeOption değeridirnull.

Şunlara uygulanır

ToString(SByte)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Önemli

Bu API, CLS uyumlu değildir.

öğesini SByte değerine Stringdönüştürür.

public:
 static System::String ^ ToString(System::SByte value);
[System.CLSCompliant(false)]
public static string ToString (sbyte value);
[<System.CLSCompliant(false)>]
static member ToString : sbyte -> string
Public Shared Function ToString (value As SByte) As String

Parametreler

value
SByte

Dönüştürülecek değer.

Döndürülenler

öğesinin SBytedize gösterimi.

Öznitelikler

Şunlara uygulanır

ToString(UInt64)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Önemli

Bu API, CLS uyumlu değildir.

öğesini UInt64 değerine Stringdönüştürür.

public:
 static System::String ^ ToString(System::UInt64 value);
[System.CLSCompliant(false)]
public static string ToString (ulong value);
[<System.CLSCompliant(false)>]
static member ToString : uint64 -> string
Public Shared Function ToString (value As ULong) As String

Parametreler

value
UInt64

Dönüştürülecek değer.

Döndürülenler

öğesinin UInt64dize gösterimi.

Öznitelikler

Şunlara uygulanır

ToString(Int64)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Int64 değerine Stringdönüştürür.

public:
 static System::String ^ ToString(long value);
public static string ToString (long value);
static member ToString : int64 -> string
Public Shared Function ToString (value As Long) As String

Parametreler

value
Int64

Dönüştürülecek değer.

Döndürülenler

öğesinin Int64dize gösterimi.

Şunlara uygulanır

ToString(Boolean)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Boolean değerine Stringdönüştürür.

public:
 static System::String ^ ToString(bool value);
public static string ToString (bool value);
static member ToString : bool -> string
Public Shared Function ToString (value As Boolean) As String

Parametreler

value
Boolean

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Boolean, yani "true" veya "false".

Şunlara uygulanır

ToString(Int16)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Int16 değerine Stringdönüştürür.

public:
 static System::String ^ ToString(short value);
public static string ToString (short value);
static member ToString : int16 -> string
Public Shared Function ToString (value As Short) As String

Parametreler

value
Int16

Dönüştürülecek değer.

Döndürülenler

öğesinin Int16dize gösterimi.

Örnekler

Aşağıdaki örnek, veri türlerini dizeye dönüştürür ve ardından bilgileri konsola yazar.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   //Define the order data.  They will be converted to string 
   //before being written out.
   Int16 custID = 32632;
   String^ orderID = "367A54";
   DateTime orderDate = DateTime::Now;
   Double price = 19.95;
   
   //Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;
   
   //Write an element (this one is the root)
   writer->WriteStartElement( "order" );
   
   //Write the order date.
   writer->WriteAttributeString( "date", XmlConvert::ToString( orderDate, "yyyy-MM-dd" ) );
   
   //Write the order time.
   writer->WriteAttributeString( "time", XmlConvert::ToString( orderDate, "HH:mm:ss" ) );
   
   //Write the order data.
   writer->WriteElementString( "orderID", orderID );
   writer->WriteElementString( "custID", XmlConvert::ToString( custID ) );
   writer->WriteElementString( "price", XmlConvert::ToString( price ) );
   
   //Write the close tag for the root element
   writer->WriteEndElement();
   
   //Write the XML and close the writer
   writer->Close();
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    //Define the order data.  They will be converted to string
    //before being written out.
    Int16 custID = 32632;
    String orderID = "367A54";
    DateTime orderDate = new DateTime();
    orderDate = DateTime.Now;
    Double price = 19.95;

    //Create a writer that outputs to the console.
    XmlTextWriter writer = new XmlTextWriter (Console.Out);
    writer.Formatting = Formatting.Indented;

    //Write an element (this one is the root)
    writer.WriteStartElement("order");

    //Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"));

    //Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"));

    //Write the order data.
    writer.WriteElementString("orderID", orderID);
    writer.WriteElementString("custID", XmlConvert.ToString(custID));
    writer.WriteElementString("price", XmlConvert.ToString(price));

    //Write the close tag for the root element
    writer.WriteEndElement();

    //Write the XML and close the writer
    writer.Close();
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    'Define the order data.  They will be converted to string
    'before being written out.
    Dim custID as Int16 = 32632
    Dim orderID as String = "367A54"
    Dim orderDate as DateTime 
    orderDate = DateTime.Now
    Dim price as Double = 19.95

    'Create a writer that outputs to the console.
    Dim writer as XmlTextWriter = new XmlTextWriter (Console.Out)
    'Use indenting for readability
    writer.Formatting = Formatting.Indented
    
    'Write an element (this one is the root)
    writer.WriteStartElement("order")

    'Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"))

    'Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"))
    
    'Write the order data.
    writer.WriteElementString("orderID", orderID)
    writer.WriteElementString("custID", XmlConvert.ToString(custID))
    writer.WriteElementString("price", XmlConvert.ToString(price))

    'Write the close tag for the root element
    writer.WriteEndElement()
             

    'Write the XML and close the writer
    writer.Flush()
    writer.Close()  

  end sub
end class

Şunlara uygulanır

ToString(Guid)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Guid değerine Stringdönüştürür.

public:
 static System::String ^ ToString(Guid value);
public static string ToString (Guid value);
static member ToString : Guid -> string
Public Shared Function ToString (value As Guid) As String

Parametreler

value
Guid

Dönüştürülecek değer.

Döndürülenler

öğesinin Guiddize gösterimi.

Şunlara uygulanır

ToString(Double)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Double öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(double value);
public static string ToString (double value);
static member ToString : double -> string
Public Shared Function ToString (value As Double) As String

Parametreler

value
Double

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Double.

Örnekler

Aşağıdaki örnek, veri türlerini dizeye dönüştürür ve ardından bilgileri konsola yazar.

#using <System.Xml.dll>

using namespace System;
using namespace System::IO;
using namespace System::Xml;
int main()
{
   
   //Define the order data.  They will be converted to string 
   //before being written out.
   Int16 custID = 32632;
   String^ orderID = "367A54";
   DateTime orderDate = DateTime::Now;
   Double price = 19.95;
   
   //Create a writer that outputs to the console.
   XmlTextWriter^ writer = gcnew XmlTextWriter( Console::Out );
   writer->Formatting = Formatting::Indented;
   
   //Write an element (this one is the root)
   writer->WriteStartElement( "order" );
   
   //Write the order date.
   writer->WriteAttributeString( "date", XmlConvert::ToString( orderDate, "yyyy-MM-dd" ) );
   
   //Write the order time.
   writer->WriteAttributeString( "time", XmlConvert::ToString( orderDate, "HH:mm:ss" ) );
   
   //Write the order data.
   writer->WriteElementString( "orderID", orderID );
   writer->WriteElementString( "custID", XmlConvert::ToString( custID ) );
   writer->WriteElementString( "price", XmlConvert::ToString( price ) );
   
   //Write the close tag for the root element
   writer->WriteEndElement();
   
   //Write the XML and close the writer
   writer->Close();
}
using System;
using System.IO;
using System.Xml;

public class Sample
{
  public static void Main()
  {

    //Define the order data.  They will be converted to string
    //before being written out.
    Int16 custID = 32632;
    String orderID = "367A54";
    DateTime orderDate = new DateTime();
    orderDate = DateTime.Now;
    Double price = 19.95;

    //Create a writer that outputs to the console.
    XmlTextWriter writer = new XmlTextWriter (Console.Out);
    writer.Formatting = Formatting.Indented;

    //Write an element (this one is the root)
    writer.WriteStartElement("order");

    //Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"));

    //Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"));

    //Write the order data.
    writer.WriteElementString("orderID", orderID);
    writer.WriteElementString("custID", XmlConvert.ToString(custID));
    writer.WriteElementString("price", XmlConvert.ToString(price));

    //Write the close tag for the root element
    writer.WriteEndElement();

    //Write the XML and close the writer
    writer.Close();
  }
}
Imports System.IO
Imports System.Xml

public class Sample

  public shared sub Main()

    'Define the order data.  They will be converted to string
    'before being written out.
    Dim custID as Int16 = 32632
    Dim orderID as String = "367A54"
    Dim orderDate as DateTime 
    orderDate = DateTime.Now
    Dim price as Double = 19.95

    'Create a writer that outputs to the console.
    Dim writer as XmlTextWriter = new XmlTextWriter (Console.Out)
    'Use indenting for readability
    writer.Formatting = Formatting.Indented
    
    'Write an element (this one is the root)
    writer.WriteStartElement("order")

    'Write the order date.
    writer.WriteAttributeString("date", XmlConvert.ToString(orderDate, "yyyy-MM-dd"))

    'Write the order time.
    writer.WriteAttributeString("time", XmlConvert.ToString(orderDate, "HH:mm:ss"))
    
    'Write the order data.
    writer.WriteElementString("orderID", orderID)
    writer.WriteElementString("custID", XmlConvert.ToString(custID))
    writer.WriteElementString("price", XmlConvert.ToString(price))

    'Write the close tag for the root element
    writer.WriteEndElement()
             

    'Write the XML and close the writer
    writer.Flush()
    writer.Close()  

  end sub
end class

Açıklamalar

value Double.PositiveInfinity veya Double.NegativeInfinity ise, bu yöntem sırasıyla INF veya -INF dizesini döndürür.

Ayrıca bkz.

Şunlara uygulanır

ToString(Decimal)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Decimal öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(System::Decimal value);
public static string ToString (decimal value);
static member ToString : decimal -> string
Public Shared Function ToString (value As Decimal) As String

Parametreler

value
Decimal

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Decimal.

Şunlara uygulanır

ToString(DateTimeOffset)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Sağlanan DateTimeOffset öğesini öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(DateTimeOffset value);
public static string ToString (DateTimeOffset value);
static member ToString : DateTimeOffset -> string
Public Shared Function ToString (value As DateTimeOffset) As String

Parametreler

value
DateTimeOffset

DateTimeOffset dönüştürülecek.

Döndürülenler

String Sağlanan DateTimeOffsetöğesinin gösterimi.

Örnekler

Aşağıdaki örnek, geçerli saatin gösterimini DateTimeOffset değerine Stringdönüştürür.

using System;
using System.Xml;

class Example
{
    static void Main()
    {
        // Create the DateTimeOffset object and set the time to the current time
        DateTimeOffset dto;
        dto = DateTimeOffset.Now;

        // Convert the DateTimeOffset object to a string and display the result
        string timeAsString = XmlConvert.ToString(dto);
        Console.WriteLine(timeAsString);
    }
}
Imports System.Xml

Module Module1
    Sub Main()

        ' Create the DateTimeOffset object and set the time to the current time
        Dim dto As DateTimeOffset
        dto = DateTimeOffset.Now

        ' Convert the DateTimeOffset object to a string and display the result
        Dim timeAsString As String = XmlConvert.ToString(dto)
        Console.WriteLine(timeAsString)

    End Sub
End Module

Şunlara uygulanır

ToString(DateTime)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

Dikkat

Use XmlConvert.ToString() that takes in XmlDateTimeSerializationMode

Dikkat

Use XmlConvert.ToString() that accepts an XmlDateTimeSerializationMode instead.

öğesini DateTime öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(DateTime value);
[System.Obsolete("Use XmlConvert.ToString() that takes in XmlDateTimeSerializationMode")]
public static string ToString (DateTime value);
[System.Obsolete("Use XmlConvert.ToString() that accepts an XmlDateTimeSerializationMode instead.")]
public static string ToString (DateTime value);
public static string ToString (DateTime value);
[<System.Obsolete("Use XmlConvert.ToString() that takes in XmlDateTimeSerializationMode")>]
static member ToString : DateTime -> string
[<System.Obsolete("Use XmlConvert.ToString() that accepts an XmlDateTimeSerializationMode instead.")>]
static member ToString : DateTime -> string
static member ToString : DateTime -> string
Public Shared Function ToString (value As DateTime) As String

Parametreler

value
DateTime

Dönüştürülecek değer.

Döndürülenler

yyyy-AA-ggTHH:dd:dd:ss biçiminde bir dize gösterimi DateTime ; burada 'T' sabit değişmez değerdir.

Öznitelikler

Açıklamalar

Not

XmlConvert.ToString(DateTime) yöntemi, .NET Framework 2.0 sürümünde kullanımdan kaldırılmıştır ve yöntemiyle XmlConvert.ToString(DateTime, XmlDateTimeSerializationMode) değiştirilmiştir. Önerilen mod şeklindedir RoundtripKind. Tam eşleşme bekleniyorsa, lütfen biçim dizesiyle yyyy-MM-ddTHH:mm:ss.fffffffzzzzzzkullanınXmlConvert.ToString(DateTime, String).

Şunlara uygulanır

ToString(Char)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Char öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(char value);
public static string ToString (char value);
static member ToString : char -> string
Public Shared Function ToString (value As Char) As String

Parametreler

value
Char

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Char.

Şunlara uygulanır

ToString(Byte)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Byte öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(System::Byte value);
public static string ToString (byte value);
static member ToString : byte -> string
Public Shared Function ToString (value As Byte) As String

Parametreler

value
Byte

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Byte.

Şunlara uygulanır

ToString(Int32)

Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs
Kaynak:
XmlConvert.cs

öğesini Int32 öğesine Stringdönüştürür.

public:
 static System::String ^ ToString(int value);
public static string ToString (int value);
static member ToString : int -> string
Public Shared Function ToString (value As Integer) As String

Parametreler

value
Int32

Dönüştürülecek değer.

Döndürülenler

dize gösterimi Int32.

Şunlara uygulanır