473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

more about the using statement

Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.

using (TextReader reader = new StreamReader(fullPathname))
{
string line;
while ((line = reader.ReadLine()) != null)
{
source.Text += line + "\n";
}
}

//Tony

Jan 16 '08 #1
23 1691
On Wed, 16 Jan 2008 10:33:24 -0800, Tony Johansson
<jo*****************@telia.comwrote:
Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.
In the example you give, there's really not any difference. The reference
only ever is stored in one variable, and that variable could just as
easily have been a StreamReader.

But since StreamReader and StringReader simply implement the abstract
TextReader class without adding anything new, it's nice to use them as
TextReaders. The same thing would apply to any other class someone might
derive from TextReader. That way the code is more general-purpose and
doesn't depend on a specific implementation of TextReader. Of course,
usually this would be a matter of passing the local variable to some
method that takes a TextReader, and of course that can be done whether or
not the variable is declared explicitly as just a TextReader versus a
StreamReader.

Obviously at some point you need to be explicit about which class is
created, but this only needs to be done in one specific place and the rest
of the code can be more reusable by using TextReader instead.

To some extent, declaring the local variable as a TextReader just makes it
that much more clear that the code within the using statement isn't
dependent at all on the reader being a StreamReader. Here, it's likely an
issue of code readability as anything else.

Pete
Jan 16 '08 #2
A StreamReader is a "type" of TextReader and that's why the code works. If
you ask me for fruit and I pass you an apple, it is ok, because an apple is
a "type" of fruit. This isn't quite polymorphism at work here, but simple
inheritance concepts.

Having said that, since a StreamReader is a more specific "type" than a
TextReader, you probably wouldn't want to keep this line of code as it is.
You'd want to declare reader as a StreamReader so that you can take full
advantage of a StreamReader's members in the using block. As it is now,
you'd only be able to use the more generic members of a TextReader in the
using block even though you really do have a StreamReader in memory.

-Scott
"Tony Johansson" <jo*****************@telia.comwrote in message
news:U5*****************@newsb.telia.net...
Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.

using (TextReader reader = new StreamReader(fullPathname))
{
string line;
while ((line = reader.ReadLine()) != null)
{
source.Text += line + "\n";
}
}

//Tony

Jan 16 '08 #3
Hi,

In that sentence using as another meaning, it basically do two things, first
it create a scope for the variable reader and second and more importantly it
call Dispose at the end of the scope.
In this construction you do not have to close the Reader. as the Dispose
method will do it for you, even if an exception is throw inside the scope.

Of course the variable being "used" must implement IDisposable

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
"Tony Johansson" <jo*****************@telia.comwrote in message
news:U5*****************@newsb.telia.net...
Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.

using (TextReader reader = new StreamReader(fullPathname))
{
string line;
while ((line = reader.ReadLine()) != null)
{
source.Text += line + "\n";
}
}

//Tony

Jan 16 '08 #4
Scott M. <sm**@nospam.nospamwrote:
A StreamReader is a "type" of TextReader and that's why the code works. If
you ask me for fruit and I pass you an apple, it is ok, because an apple is
a "type" of fruit. This isn't quite polymorphism at work here, but simple
inheritance concepts.

Having said that, since a StreamReader is a more specific "type" than a
TextReader, you probably wouldn't want to keep this line of code as it is.
You'd want to declare reader as a StreamReader so that you can take full
advantage of a StreamReader's members in the using block. As it is now,
you'd only be able to use the more generic members of a TextReader in the
using block even though you really do have a StreamReader in memory.
I prefer to only declare variables as the minimally specific type that
I need them to be. That makes it obvious that if you need to change the
implementation that happens to be used at a later date, it's okay to do
so.

In other words, I think the code is absolutely fine as it is :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 16 '08 #5
Hi,


"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Scott M. <sm**@nospam.nospamwrote:
>Having said that, since a StreamReader is a more specific "type" than a
TextReader, you probably wouldn't want to keep this line of code as it
is.
You'd want to declare reader as a StreamReader so that you can take full
advantage of a StreamReader's members in the using block. As it is now,
you'd only be able to use the more generic members of a TextReader in the
using block even though you really do have a StreamReader in memory.

I prefer to only declare variables as the minimally specific type that
I need them to be. That makes it obvious that if you need to change the
implementation that happens to be used at a later date, it's okay to do
so.

In other words, I think the code is absolutely fine as it is :)

I totally agree with you, there is nothing wrong with that code . Not only
that but I wish that ALL the code were always written like that. I have
found a lot of places where objects that implement IDisposables are nt being
used like tht and are not being disposed after use.

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Jan 16 '08 #6
On Jan 16, 7:43 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.comwrote:
Hi,

"Jon Skeet [C# MVP]" <sk...@pobox.comwrote in messagenews:MP*********************@msnews.microso ft.com...
Scott M. <s...@nospam.nospamwrote:
Having said that, since a StreamReader is a more specific "type" than a
TextReader, you probably wouldn't want to keep this line of code as it
is.
You'd want to declare reader as a StreamReader so that you can take full
advantage of a StreamReader's members in the using block. As it is now,
you'd only be able to use the more generic members of a TextReader in the
using block even though you really do have a StreamReader in memory.
I prefer to only declare variables as the minimally specific type that
I need them to be. That makes it obvious that if you need to change the
implementation that happens to be used at a later date, it's okay to do
so.
In other words, I think the code is absolutely fine as it is :)

I totally agree with you, there is nothing wrong with that code . Not only
that but I wish that ALL the code were always written like that. I have
found a lot of places where objects that implement IDisposables are nt being
used like tht and are not being disposed after use.

--
Ignacio Machinhttp://www.laceupsolutions.com
Mobile & warehouse Solutions.

Nothing wrong with the code...

good use of the using statement - I always try to use the using
statement on any object which implements IDispose - but surely the
StringBuilder object should be employed instead of the string
concatination within a loop!!
Jan 16 '08 #7
<ma*************@ntlworld.comwrote:

<snip>
Nothing wrong with the code...

good use of the using statement - I always try to use the using
statement on any object which implements IDispose - but surely the
StringBuilder object should be employed instead of the string
concatination within a loop!!
Oh absolutely. My mistake for not being clearer - I was only commenting
on the declaration of the variable as a TextReader.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 16 '08 #8
Hello!

Because the TextReader is an abstract class it mean that some method in the
TextReader class does not have an implementation. A wonder which method in
the TextReader class does not have an implementation which mean that the
method implemention must be done in the derived class in this case the
StreamReader class.

//Tony
"Peter Duniho" <Np*********@nnowslpianmk.comskrev i meddelandet
news:op***************@petes-computer.local...
On Wed, 16 Jan 2008 10:33:24 -0800, Tony Johansson
<jo*****************@telia.comwrote:
>Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.

In the example you give, there's really not any difference. The reference
only ever is stored in one variable, and that variable could just as
easily have been a StreamReader.

But since StreamReader and StringReader simply implement the abstract
TextReader class without adding anything new, it's nice to use them as
TextReaders. The same thing would apply to any other class someone might
derive from TextReader. That way the code is more general-purpose and
doesn't depend on a specific implementation of TextReader. Of course,
usually this would be a matter of passing the local variable to some
method that takes a TextReader, and of course that can be done whether or
not the variable is declared explicitly as just a TextReader versus a
StreamReader.

Obviously at some point you need to be explicit about which class is
created, but this only needs to be done in one specific place and the rest
of the code can be more reusable by using TextReader instead.

To some extent, declaring the local variable as a TextReader just makes it
that much more clear that the code within the using statement isn't
dependent at all on the reader being a StreamReader. Here, it's likely an
issue of code readability as anything else.

Pete

Jan 16 '08 #9
On Wed, 16 Jan 2008 13:26:21 -0800, Tony Johansson
<jo*****************@telia.comwrote:
Hello!

Because the TextReader is an abstract class it mean that some method in
the
TextReader class does not have an implementation. A wonder which method
in
the TextReader class does not have an implementation which mean that the
method implemention must be done in the derived class in this case the
StreamReader class.
Is that a question? If so, you may want to rephrase it. Possibly
including a question mark, to make it clear where the question is. I have
no idea what, if any, response might be expected with respect to the above.

Pete
Jan 16 '08 #10
Peter Duniho <Np*********@nnowslpianmk.comwrote:
Because the TextReader is an abstract class it mean that some method in
the
TextReader class does not have an implementation. A wonder which method
in
the TextReader class does not have an implementation which mean that the
method implemention must be done in the derived class in this case the
StreamReader class.

Is that a question? If so, you may want to rephrase it. Possibly
including a question mark, to make it clear where the question is. I have
no idea what, if any, response might be expected with respect to the above.
I should point out, however, that a class being abstract *doesn't* mean
that some methods aren't implemented. You can have an abstract class
without any abstract members.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 16 '08 #11
So, would you declare a new textbox as a control?
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Scott M. <sm**@nospam.nospamwrote:
>A StreamReader is a "type" of TextReader and that's why the code works.
If
you ask me for fruit and I pass you an apple, it is ok, because an apple
is
a "type" of fruit. This isn't quite polymorphism at work here, but
simple
inheritance concepts.

Having said that, since a StreamReader is a more specific "type" than a
TextReader, you probably wouldn't want to keep this line of code as it
is.
You'd want to declare reader as a StreamReader so that you can take full
advantage of a StreamReader's members in the using block. As it is now,
you'd only be able to use the more generic members of a TextReader in the
using block even though you really do have a StreamReader in memory.

I prefer to only declare variables as the minimally specific type that
I need them to be. That makes it obvious that if you need to change the
implementation that happens to be used at a later date, it's okay to do
so.

In other words, I think the code is absolutely fine as it is :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

Jan 16 '08 #12
On Wed, 16 Jan 2008 14:53:43 -0800, Scott M. <sm**@nospam.nospamwrote:
So, would you declare a new textbox as a control?
I can't speak for Jon, but if Control was the minimally specific type I
needed the variable to be, then yes. I would.

Of course, ordinarily if you've got a TextBox instance, you are interested
in doing TextBox-like things with it. Like accessing the lines of the
text, or modifying or looking at the selection, or similar. In that case,
Control is not a minimally specific type needed for the variable and
should not be declared that way. You'd want to declare it with the full
type.

But sure...if all you ever do is get or set the Text property of the
TextBox, why not just declare it as a Control? (The VS Designer's default
behavior notwithstanding, of course).

Pete
Jan 16 '08 #13
But sure...if all you ever do is get or set the Text property of the
TextBox, why not just declare it as a Control? (The VS Designer's default
behavior notwithstanding, of course).
Because it limits me from using the control as it really is stored in memory
without a cast involved. Sure, I understand the potential benefits of what
you describe, but for me, I do that as the exception (no .NET pun intended),
not the rule. In the SreamReader/TextReader code that the OP shows, I can
understand it, considering that the TextReader is an abstract class. I can
also fully understand the benefits of using the minimally specific type or
interfaces when declaring method parameters (polymorphism). I just don't
agree that this is the best practice to follow as a rule for object
variables.
Jan 16 '08 #14
On Wed, 16 Jan 2008 15:34:08 -0800, Scott M. <sm**@nospam.nospamwrote:
>But sure...if all you ever do is get or set the Text property of the
TextBox, why not just declare it as a Control? (The VS Designer's
default
behavior notwithstanding, of course).

Because it limits me from using the control as it really is stored in
memory
without a cast involved.
???

Um. If (using the Control/TextBox example) Control is the minimally
specific type that you need the variable to be, then the fact that "it
limits you" is not a problem. Conversely, if the fact that "it limits
you" is a problem, then by definition Control would _not_ be the minimally
specific type that you need the variable to be.

You've set up a nice straw man, but otherwise I fail to see your point.
[...] I just don't
agree that this is the best practice to follow as a rule for object
variables.
No one is suggesting that you always use a base class type for your
variables instead of the actual type of the instance. In most cases, you
have a reason for creating an instance of a specific type and you would
want the full type as your variable type.

You've already acknowledged that in the example code, using TextReader
instead of StreamReader for the variable type is fine. And for the same
reason that that's fine, as a general rule if you don't care about the
more-derived type of the object instance, it's also fine to declare other
variables following the same pattern. Furthermore, doing so enhances
maintainability and reuse of the code you've written, because the code is
not unnecessarily constrained to being used with a more specific type than
it really needs.

Frankly, if you'd objected to the use of TextReader as the variable type
in the example code, I could at least see your argument as being
consistent, even if I don't agree with it. But as it is, you seem to be
making an argument just for the sake of being argumentative. I really
don't see the point in that.

Pete
Jan 16 '08 #15

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 16 Jan 2008 15:34:08 -0800, Scott M. <sm**@nospam.nospamwrote:
>>But sure...if all you ever do is get or set the Text property of the
TextBox, why not just declare it as a Control? (The VS Designer's
default
behavior notwithstanding, of course).

Because it limits me from using the control as it really is stored in
memory
without a cast involved.

???

Um. If (using the Control/TextBox example) Control is the minimally
specific type that you need the variable to be, then the fact that "it
limits you" is not a problem. Conversely, if the fact that "it limits
you" is a problem, then by definition Control would _not_ be the minimally
specific type that you need the variable to be.
Under that train of thought, why would you be making a Textbox in the first
place. Wouldn't you just declare a control variable to hold a reference to
a control on the heap? If a control is the minimally specific type, then
just make a control instance.
>
You've set up a nice straw man, but otherwise I fail to see your point.
>[...] I just don't
agree that this is the best practice to follow as a rule for object
variables.

No one is suggesting that you always use a base class type for your
variables instead of the actual type of the instance. In most cases, you
have a reason for creating an instance of a specific type and you would
want the full type as your variable type.

You've already acknowledged that in the example code, using TextReader
instead of StreamReader for the variable type is fine. And for the same
reason that that's fine, as a general rule if you don't care about the
more-derived type of the object instance, it's also fine to declare other
variables following the same pattern. Furthermore, doing so enhances
maintainability and reuse of the code you've written, because the code is
not unnecessarily constrained to being used with a more specific type than
it really needs.

Frankly, if you'd objected to the use of TextReader as the variable type
in the example code, I could at least see your argument as being
consistent, even if I don't agree with it. But as it is, you seem to be
making an argument just for the sake of being argumentative. I really
don't see the point in that.
I'm not sure where you think I'm being argumentative, since I don't consider
this an argument. I'm simply telling you what my opinion is about what to
do as a general rule. As you've said yourself above, "In most cases, you
have a reason for creating an instance of a specific type and you would want
the full type as your variable type.". I agree and that is the simple point
I was trying to make.
>
Pete

Jan 17 '08 #16
On Wed, 16 Jan 2008 16:52:47 -0800, Scott M. <sm**@nospam.nospamwrote:
Under that train of thought, why would you be making a Textbox in the
first
place.
I don't understand that question. You'd make a TextBox for the same
reason you'd ever make one: you want a control that would allow a user to
enter or otherwise interact with some text.
Wouldn't you just declare a control variable to hold a reference to
a control on the heap? If a control is the minimally specific type, then
just make a control instance.
How does that allow the user to use a TextBox?

You have to create a TextBox for the user to use it. Creating a Control
instance isn't sufficient.
I'm not sure where you think I'm being argumentative, since I don't
consider
this an argument. I'm simply telling you what my opinion is about what
to do as a general rule.
Inasmuch as your opinion conflicts with Jon's and/or mine, you are being
argumentative.
As you've said yourself above, "In most cases, you
have a reason for creating an instance of a specific type and you would
want
the full type as your variable type.". I agree and that is the simple
point
I was trying to make.
Then why didn't you say that instead of questioning the statement "I
prefer to only declare variables as the minimally specific type that I
need them to be"? Why would you question that statement if you don't have
a point that contradicts it?

Pete
Jan 17 '08 #17
Inasmuch as your opinion conflicts with Jon's and/or mine, you are being
argumentative.
Oh, well I guess using that logic I could say you are being argumentative to
me. And, anytime an opinion conflicts with others, thier is an argument.
>As you've said yourself above, "In most cases, you
have a reason for creating an instance of a specific type and you would
want
the full type as your variable type.". I agree and that is the simple
point
I was trying to make.

Then why didn't you say that instead of questioning the statement "I
prefer to only declare variables as the minimally specific type that I
need them to be"? Why would you question that statement if you don't have
a point that contradicts it?
I'm pretty sure I did say that and I'm also pretty sure that you've been the
one taking the argumentative stand.

>
Pete

Jan 17 '08 #18
On Wed, 16 Jan 2008 19:14:07 -0800, Scott M. <sm**@nospam.nospamwrote:
>Inasmuch as your opinion conflicts with Jon's and/or mine, you are being
argumentative.

Oh, well I guess using that logic I could say you are being
argumentative to
me. And, anytime an opinion conflicts with others, thier is an argument.
That's true. It may not be a vehement argument, but there's not any
question in my mind that there's an argument. The dictionary definition
of the word "argument" agrees with this viewpoint.
I'm pretty sure I did say that and I'm also pretty sure that you've been
the
one taking the argumentative stand.
We are both being argumentative. The difference is that I've stated
reasons for my position. I'm not just being argumentative for the sake of
being argumentative. I have an actual point that I am supporting.

You, on the other hand, have questioned a statement and then not only
refused to provide any justification for questioning that statement, have
decided that you agree with it after all. Without admitting that you have
(i.e. continuing to be argumentative). In other words, you insist on
disagreeing (i.e. being argumentative) without having an actual
disagreement (i.e. apparently just for the sake of being argumentative).

I have no idea. Maybe you have some _other_ reason for being
argumentative. It's obviously not because you disagree with the
philosophy Jon proposed or that I paraphrased and agreed with. You
apparently agree with the philosophy. You are, if I understand correctly,
claiming that it's not just for the sake of being argumentative. I don't
really know what's left as a reason to be argumentative, but I'm all ears
if you want to explain some other reason for arguing about something you
don't disagree with.

Pete
Jan 17 '08 #19
Scott M. <sm**@nospam.nospamwrote:
So, would you declare a new textbox as a control?
As Peter suggested, *if* I only needed to use members declared on
Control, then yes I would.

Your argument of "that stops me from using members declared only on
TextBox" immediately moves us away from the initial premise, so isn't
relevant. While the premise holds, take the suggested course of action.
When it doesn't hold, don't.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Jan 17 '08 #20
On Thu, 17 Jan 2008 15:39:59 -0800, Scott M. <sm**@nospam.nospamwrote:
Actually, what I stated was an opinion and I stated as much.
Actually, you didn't really state much of anything in an explicit way.
Jon made a perfectly reasonable statement about a philosophy for choosing
the type for a variable declaration, and you wrote a question that implied
(but did not say directly) that you disagreed with it.
I don't need
to provide any facts or supporting evidence when stating an opinion.
Absolutely true. I cannot disagree with that. That does not stop anyone
from asking if you have a _good reason_ for your opinion, or from you
explaining your reason, good or otherwise, for having formed that opinion.

Now, if you fail to state a good reason for your opinion, most people will
rightly decide your opinion is flawed. You have every right to continue
to hold it, but that doesn't make it any less flawed.
If you are really going to say that anytime two parties have conflicting
viewpoints, they are in an agument, then there is really no point to any
further discussion on this point, since I believe that that viewpoint is
absolutely absurd.
You might try looking the word "argument" up in a dictionary some time.
It seems likely that what you'll read will surprise you. In any case,
since this discussion hinges not on the definition of "argument", but
rather on the question of choosing a type for a variable declaration, I
think it's pretty stupid to abandon the discussion based on a disagreement
about the former. How is that at all relevant?
Good day.
Certainly it has been for me. Thanks for caring.

Pete
Jan 18 '08 #21
Actually, what I stated was an opinion and I stated as much. I don't need
to provide any facts or supporting evidence when stating an opinion.

If you are really going to say that anytime two parties have conflicting
viewpoints, they are in an agument, then there is really no point to any
further discussion on this point, since I believe that that viewpoint is
absolutely absurd.

Good day.

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 16 Jan 2008 19:14:07 -0800, Scott M. <sm**@nospam.nospamwrote:
>>Inasmuch as your opinion conflicts with Jon's and/or mine, you are being
argumentative.

Oh, well I guess using that logic I could say you are being
argumentative to
me. And, anytime an opinion conflicts with others, thier is an argument.

That's true. It may not be a vehement argument, but there's not any
question in my mind that there's an argument. The dictionary definition
of the word "argument" agrees with this viewpoint.
>I'm pretty sure I did say that and I'm also pretty sure that you've been
the
one taking the argumentative stand.

We are both being argumentative. The difference is that I've stated
reasons for my position. I'm not just being argumentative for the sake of
being argumentative. I have an actual point that I am supporting.

You, on the other hand, have questioned a statement and then not only
refused to provide any justification for questioning that statement, have
decided that you agree with it after all. Without admitting that you have
(i.e. continuing to be argumentative). In other words, you insist on
disagreeing (i.e. being argumentative) without having an actual
disagreement (i.e. apparently just for the sake of being argumentative).

I have no idea. Maybe you have some _other_ reason for being
argumentative. It's obviously not because you disagree with the
philosophy Jon proposed or that I paraphrased and agreed with. You
apparently agree with the philosophy. You are, if I understand correctly,
claiming that it's not just for the sake of being argumentative. I don't
really know what's left as a reason to be argumentative, but I'm all ears
if you want to explain some other reason for arguing about something you
don't disagree with.

Pete

Jan 18 '08 #22
Hi,

<ma*************@ntlworld.comwrote in message
news:cc**********************************@v4g2000h sf.googlegroups.com...
>
Nothing wrong with the code...

good use of the using statement - I always try to use the using
statement on any object which implements IDispose - but surely the
StringBuilder object should be employed instead of the string
concatination within a loop!!
My bad, I did not notice it :)

--
Ignacio Machin
http://www.laceupsolutions.com
Mobile & warehouse Solutions.
Jan 18 '08 #23
Tony Johansson wrote:
Hello!

I just wonder what is the point of having the reader variable declared as
TextReader in the snippet below..
Is it because of using the polymorfism on the reader variable perhaps.

using (TextReader reader = new StreamReader(fullPathname))
{
string line;
while ((line = reader.ReadLine()) != null)
{
source.Text += line + "\n";
}
}
Have you tried:

using (TextReader reader = new StreamReader(fullPathname))
{
source.Text = reader.ReadToEnd();
}

Hilton
Feb 20 '08 #24

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: bearophile | last post by:
Ville Vainio: >It's highly typical for the newbies to suggest improvements to the >language. They will usually learn that they are wrong, but the >discussion that ensues can be fruitfull anyway...
1
by: M Wells | last post by:
Hi All, Further to my previous long-winded question about a situation in which we appear to be mysteriously losing data from our mssql2k server. We discovered an update statement, in the...
3
by: Colin Spalding | last post by:
In Access, if I want to update one table with information from another, all I need to do is to create an Update query with the two tables, link the primary keys and reference the source...
7
by: Tony Johansson | last post by:
Hello Experts! I have the following Array template class see below. I execute these three statements statement 1: Array<int> x(5); statement 2: cin >>x; statement 3: Array<int>::element_type ...
5
by: Rod | last post by:
I have a client site where the code below has been working happily for at least four months. The site is using SQL Server 7. The code is ASP.NET Last week an error appeared related to the...
4
by: allenevaalleneva | last post by:
Q:Write a program that prints the numbers 1 to 4 on the same line with with each pair of adjacent numbers separated by one space. Do this several ways: a) Using one statement with one stream...
8
by: rbg | last post by:
I did use query plans to find out more. ( Please see the thread BELOW) I have a question on this, if someone can help me with that it will be great. In my SQL query that selects data from table,...
15
by: Dave | last post by:
I am getting the error above intermittantly with an ASP 3.0 page using an MS Access 2003 database. I have searched Google extensively and found the following possible causes for this error: A...
1
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
Is using a jump statement more faster than using if statement with a jump statement example for(int i=0; i < 10; i++) { if(a == null) {
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.