Console::Write Method (Object^)

 

Writes the text representation of the specified object to the standard output stream.

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

public:
[HostProtectionAttribute(SecurityAction::LinkDemand, UI = true)]
static void Write(
	Object^ value
)

Parameters

value
Type: System::Object^

The value to write, or null.

Exception Condition
IOException

An I/O error occurred.

If value is null, nothing is written and no exception is thrown. Otherwise, the ToString method of value is called to produce its string representation, and the resulting string is written to the standard output stream.

The following example illustrates the use of the Write method.

int main()
{
   array<String^>^lineInputArr = {"1   2.2   hello	TRUE","2   5.22   bye	FALSE","3   6.38   see ya'	TRUE"};
   for ( Int32 i = 0; i < 3; i++ )
   {
      String^ lineInput = lineInputArr->GetValue( i )->ToString();
      String^ aChar =  "\t";
      array<String^>^fields = lineInput->Split( aChar->ToCharArray() );
      Boolean isFirstField = true;
      for ( Int32 i = 0; i < fields->Length; 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( fields[ i ] ) ) );
         }
         catch ( FormatException^ ) 
         {
            Console::Write( fields[ i ] );
         }


      }
      Console::WriteLine();

   }
}

UIPermission

for modifying safe top-level windows and subwindows. Associated enumeration: UIPermissionWindow::SafeTopLevelWindows

.NET Framework
Available since 1.1
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: