manzoor10
January 20th, 2009, 11:24 AM
#include "stdafx.h"
using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::IO;
using namespace System::Text;
void main(void)
{
Stream^ fS = gcnew FileStream("D:\\TextOut.txt", FileMode::Create, FileAccess::Write);
StreamWriter^ sWriter = gcnew StreamWriter(fS);
Console::WriteLine("Encoding type : " + sWriter->Encoding->ToString());
Console::WriteLine("Format Provider : " + sWriter->FormatProvider->ToString());
sWriter->WriteLine("Today is {0}", DateTime::Today.DayOfWeek);
sWriter->WriteLine("Today we will mostly be using StreamWriter");
for (int i = 0; i < 5; i++)
sWriter->WriteLine("Value {0}, its square is {1}", i, i * i);
sWriter->Write("Arrays can be written : ");
// here if I declare the array as 'array<char>', then comes an error
array<System::Char>^ myArray = gcnew array<System::Char>(5) { 'a', 'r', 'r', 'a', 'y' };
sWriter->Write(myArray);
sWriter->WriteLine("\r\nAnd parts of arrays can be written too");
// the error comes up here
sWriter->Write(myArray, 0, 3);
sWriter->Close();
fS->Close();
}
The error is
error C2664: 'void System::IO::TextWriter::Write(cli::array<Type,dimension> ^,int,int)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'cli::array<Type,dimension> ^'.
And there is one more thing,
the Write() method for StreamWriter have only four overloads, but in MSDN it shows more than it 17... Why whats wrong here?
using namespace System;
using namespace System::Net;
using namespace System::Net::Sockets;
using namespace System::IO;
using namespace System::Text;
void main(void)
{
Stream^ fS = gcnew FileStream("D:\\TextOut.txt", FileMode::Create, FileAccess::Write);
StreamWriter^ sWriter = gcnew StreamWriter(fS);
Console::WriteLine("Encoding type : " + sWriter->Encoding->ToString());
Console::WriteLine("Format Provider : " + sWriter->FormatProvider->ToString());
sWriter->WriteLine("Today is {0}", DateTime::Today.DayOfWeek);
sWriter->WriteLine("Today we will mostly be using StreamWriter");
for (int i = 0; i < 5; i++)
sWriter->WriteLine("Value {0}, its square is {1}", i, i * i);
sWriter->Write("Arrays can be written : ");
// here if I declare the array as 'array<char>', then comes an error
array<System::Char>^ myArray = gcnew array<System::Char>(5) { 'a', 'r', 'r', 'a', 'y' };
sWriter->Write(myArray);
sWriter->WriteLine("\r\nAnd parts of arrays can be written too");
// the error comes up here
sWriter->Write(myArray, 0, 3);
sWriter->Close();
fS->Close();
}
The error is
error C2664: 'void System::IO::TextWriter::Write(cli::array<Type,dimension> ^,int,int)' : cannot convert parameter 1 from 'cli::array<Type> ^' to 'cli::array<Type,dimension> ^'.
And there is one more thing,
the Write() method for StreamWriter have only four overloads, but in MSDN it shows more than it 17... Why whats wrong here?