C# Console WriteLine(String, Object, Object, Object, Object)

Description

Console WriteLine(String, Object, Object, Object, Object) writes the text representation of the specified objects and variable-length parameter list, followed by the current line terminator, to the standard output stream using the specified format information.

Syntax

Console.WriteLine(String, Object, Object, Object, Object) has the following syntax.


C# does not support methods that use variable length arguments (varargs).
The compiler automatically resolves calls to this method to the same method that uses a parameter array.

Parameters

Console.WriteLine(String, Object, Object, Object, Object) has the following parameters.

  • format - A composite format string (see Remarks).
  • arg0 - The first object to write using format.
  • arg1 - The second object to write using format.
  • arg2 - The third object to write using format.
  • arg3 - The fourth object to write using format.

Returns

Console.WriteLine(String, Object, Object, Object, Object) method returns

Example

The following example illustrates the use of variable arguments with the WriteLine(String, Object, Object, Object, Object) method.


//from   ww w. j a va  2  s. com
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Console.WriteLine("{0}{4}{1}{4}{2}{4}{3}", "aasdf", 1, 2, 3, Environment.NewLine);
  }
}

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