C# String ToString()

Description

String ToString() returns this instance of String; no actual conversion is performed.

Syntax

String.ToString() has the following syntax.


public override string ToString()

Returns

String.ToString() method returns The current string.

Example

The following example demonstrates the ToString method.


using System;// ww  w.  ja va  2  s  .  com

class stringToString {
    public static void Main() {
        String str1 = "123";
        String str2 = "abc";
    
        str2 = str1.ToString();
        Console.WriteLine(str2);
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version