Sunday, January 22, 2012

More output format for Console::Write()/WriteLine()

Example:
// CLRConsole.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{

 Console::WriteLine(L"More output format for Console::Write()/WriteLine()");
 Console::WriteLine(L"C/c: in Currency Format: {0:C4}", 123.456789);
 Console::WriteLine(L"D/d: output integer as decimal: {0:D4}", 123);
 Console::WriteLine(L"E/e: output floating point in scientific format: {0:E4}", 123.456789);
 Console::WriteLine(L"F/f: output floating point in fixed-point format: {0:F4}", 123.456789);
 Console::WriteLine(L"G/g: output in compact form: {0:G5}", 123.456789);
 Console::WriteLine(L"N/n: output with comma if needed: {0:N}", 12345.6789);
 Console::WriteLine(L"X/x: output integer as hexadecimal: {0:D4}", 123);

 Console::ReadLine();
    return 0;
}

output format for Console::Write()/WriteLine()

No comments:

Post a Comment