C# String String(Char, Int32)

Description

String String(Char, Int32) initializes a new instance of the String class to the value indicated by a specified Unicode character repeated a specified number of times.

Syntax

String.String(Char, Int32) has the following syntax.


public String(
  char c,
  int count
)

Parameters

String.String(Char, Int32) has the following parameters.

  • c - A Unicode character.
  • count - The number of times c occurs.

Example


//from   w  w  w.  j  a v  a  2 s  .co  m

using System;
public class MainClass{
  public static void Main(String[] argv){  
    System.Console.WriteLine(new String('a',2));
  }
}
    

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