From: shapper on
Hello,

I need to us a TextWriter as an argument of a method:

System.IO.TextWriter t;
_parser.Go(t);

However I get, on the second line, the error:
Use of unassigned local variable 't'

But I am not able to do the following:
System.IO.TextWriter t = new TextWriter();

How can I solve this?

Thanks,
Miguel


From: Family Tree Mike on
On 5/20/2010 12:10 PM, shapper wrote:
> Hello,
>
> I need to us a TextWriter as an argument of a method:
>
> System.IO.TextWriter t;
> _parser.Go(t);
>
> However I get, on the second line, the error:
> Use of unassigned local variable 't'
>
> But I am not able to do the following:
> System.IO.TextWriter t = new TextWriter();
>
> How can I solve this?
>
> Thanks,
> Miguel
>
>

TextWriter is abstract. You can use StreamWriter, or some other class
that extends TextWriter.

--
Mike
From: Jackie on
On 5/20/2010 18:10, shapper wrote:
> Hello,
>
> I need to us a TextWriter as an argument of a method:
>
> System.IO.TextWriter t;
> _parser.Go(t);
>
> However I get, on the second line, the error:
> Use of unassigned local variable 't'
>
> But I am not able to do the following:
> System.IO.TextWriter t = new TextWriter();
>
> How can I solve this?
>
> Thanks,
> Miguel
>
>


TextWriter is an abstract class so you can't instantiate it. You must
use one of the derived classes such as StreamWriter and StringWriter.

http://msdn.microsoft.com/en-us/library/system.io.textwriter.aspx
From: Jeff Johnson on
"shapper" <mdmoura(a)gmail.com> wrote in message
news:73d679e2-a3bf-47c3-a39f-7ac550d4f7f2(a)o1g2000vbe.googlegroups.com...

> I need to us a TextWriter as an argument of a method:
>
> System.IO.TextWriter t;
> _parser.Go(t);
>
> However I get, on the second line, the error:
> Use of unassigned local variable 't'
>
> But I am not able to do the following:
> System.IO.TextWriter t = new TextWriter();

RTFM. TextWriter is abstract; you can't create instances of it. Create a
StreamWriter.


From: Jackie on
On 5/20/2010 18:26, Jeff Johnson wrote:
> RTFM. TextWriter is abstract; you can't create instances of it. Create a
> StreamWriter.
>

Reading The Fantastic Manual may be a good idea, indeed. :)