char
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: char

  1. #1
    Join Date
    Jan 2009
    Posts
    11

    char

    Code:
    #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
    Code:
    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?

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: char

    I just build your code with VS2005 and VS2008 and there is no error. What version are you using?
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center