Export (0) Print
Expand All

Console.Write Method (Int64)

Writes the text representation of the specified 64-bit signed integer value to the standard output stream.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static void Write (
	long value
)
public static void Write (
	long value
)
public static function Write (
	value : long
)
Not applicable.

Parameters

value

The value to write.

Exception typeCondition

IOException

An I/O error occurred.

The text representation of value is produced by calling the Int64.ToString method.

The following code example illustrates the use of the Write method.

public class FormatConverter {
    public static void Main(string[] args) {
        string lineInput;
        while ((lineInput = Console.ReadLine()) != null) {
            string[] fields = lineInput.Split(new char[] {'\t'});
            bool isFirstField = true;
            foreach(string item in fields) {
                if (isFirstField)
                    isFirstField = false;
                else
                    Console.Write(',');
                // If the field represents a boolean, replace with a numeric representation.
                try {
                    Console.Write(Convert.ToByte(Convert.ToBoolean(item)));
                }
                catch(FormatException) {
                    Console.Write(item);
                }
            }
            Console.WriteLine();
        }
    }
}

public class FormatConverter
{
    public static void main(String[] args)
    {
        String lineInput;

        while (((lineInput = Console.ReadLine()) != null)) {
            String fields[] = lineInput.Split(new char[] { '\t' });
            boolean isFirstField = true;
            String item = null;
            for (int iCtr = 0; iCtr < fields.length; iCtr++) {
                item = fields[iCtr];
                if (isFirstField) {                
                    isFirstField = false;
                }
                else {                
                    Console.Write(',');
                } 
                // If the field represents a boolean, replace with a numeric 
                // representation.
                try {                
                    Console.Write(Convert.ToByte(Convert.ToBoolean(item)));
                }
                catch (FormatException exp) {                
                    Console.Write(item);
                }
            }
            Console.WriteLine();
        }
    } //main
} //FormatConverter

var lineInput : String;
while ((lineInput = Console.ReadLine()) != null) {
    var fields : String[] = lineInput.Split(char[](['\t']));
    var isFirstField : Boolean = true;
    for(var i in fields) {
        var item = fields[i];
        if (isFirstField)
            isFirstField = false;
        else
            Console.Write(',');
        // If the field represents a boolean, replace with a numeric representation.
        try {
            Console.Write(Convert.ToByte(Convert.ToBoolean(item)));
        }
        catch(FormatException) {
            Console.Write(item);
        }
    }
    Console.WriteLine();
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft