473,795 Members | 3,100 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

can i get next ReadLine Value of currentStr

what i know is...

while ((currentStr = sr.ReadLine()) != null)
{
in this area,
can i get next ReadLine Value of currentStr

}

best regard,,

Dec 1 '06 #1
3 1827
Not with that sort of construct.

If you want to deal with 2 lines at a time then you need to do it slightly
differently, something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
string _line1 = sr.ReadLine();
}

If you to deal with 1 line at a time but you need to reference something in
the subsequent line then you need to do it slightly differently again,
something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
_line1 = _line2;
}
"PointMan" <so**********@g mail.comwrote in message
news:uM******** *****@TK2MSFTNG P04.phx.gbl...
what i know is...

while ((currentStr = sr.ReadLine()) != null)
{
in this area,
can i get next ReadLine Value of currentStr

}
best regard,,

Dec 1 '06 #2
thank you for your reply
it helps to me...but i still have some problems...
if Data is 12345,

while ((currentStr = sr.ReadLine()) != null)
{
if((nextStr = sr.ReadLine()) != null);

wanna read like below
currentStr = sr.ReadLine() - read 1
nextStr = sr.ReadLine()- read 2
currentStr = sr.ReadLine()- read 2
nextStr = sr.ReadLine()- read 3

how can i solve this.,.
"Stephany Young" <noone@localhos twrote in message
news:Ob******** ******@TK2MSFTN GP04.phx.gbl...
Not with that sort of construct.

If you want to deal with 2 lines at a time then you need to do it slightly
differently, something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
string _line1 = sr.ReadLine();
}

If you to deal with 1 line at a time but you need to reference something
in the subsequent line then you need to do it slightly differently again,
something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
_line1 = _line2;
}
"PointMan" <so**********@g mail.comwrote in message
news:uM******** *****@TK2MSFTNG P04.phx.gbl...
>what i know is...

while ((currentStr = sr.ReadLine()) != null)
{
in this area,
can i get next ReadLine Value of currentStr

}
best regard,,

Dec 1 '06 #3
I get the impression that you don't really understand what your loop is
really doing.

What 'while ((currentStr = sr.ReadLine()) != null)' is doing is: Start at
the beginning of the file and read each line in turn into currentStr until
there are no more lines.

At the beginning of the loop, the 'pointer is at the beginning of the first
line. Each time you execute sr.ReadLine(), the line beginning at the
'pointer' is read and the 'pointer' is advanced to the beginning of the next
line.

It would appear that you think that you can use sr.ReadLine() to read some
arbitrary text from somewhere.

You need to clearly define what your goal is and then use the appropriate
techniques to achieve it.

"PointMan" <so**********@g mail.comwrote in message
news:u2******** ******@TK2MSFTN GP06.phx.gbl...
thank you for your reply
it helps to me...but i still have some problems...
if Data is 12345,

while ((currentStr = sr.ReadLine()) != null)
{
if((nextStr = sr.ReadLine()) != null);

wanna read like below
currentStr = sr.ReadLine() - read 1
nextStr = sr.ReadLine()- read 2
currentStr = sr.ReadLine()- read 2
nextStr = sr.ReadLine()- read 3

how can i solve this.,.
"Stephany Young" <noone@localhos twrote in message
news:Ob******** ******@TK2MSFTN GP04.phx.gbl...
>Not with that sort of construct.

If you want to deal with 2 lines at a time then you need to do it
slightly differently, something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
string _line1 = sr.ReadLine();
}

If you to deal with 1 line at a time but you need to reference something
in the subsequent line then you need to do it slightly differently again,
something like:

string _line1 = sr.ReadLine();
while (_line1 != null)
{
string _line2 = sr.ReadLine();
if (_line2 == null) break;
// you now have both lines in memory
// do some stuff with them
_line1 = _line2;
}
"PointMan" <so**********@g mail.comwrote in message
news:uM******* ******@TK2MSFTN GP04.phx.gbl...
>>what i know is...

while ((currentStr = sr.ReadLine()) != null)
{
in this area,
can i get next ReadLine Value of currentStr

}
best regard,,


Dec 1 '06 #4

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

Similar topics

3
8712
by: peter leonard | last post by:
Hi, I having a problem with reading each line from a text file. For example, the file is a text file named 'test.txt' with the following content : line 1 line 2 line 3 line 4 line 5
12
53325
by: Mike Maxwell | last post by:
When I invoke readline() in a for loop, why does it return a series of one-char strings, rather than the full line? >>> for sL in sys.stdin.readline(): print sL .... abc a b c
19
10648
by: les_ander | last post by:
Hi, suppose I am reading lines from a file or stdin. I want to just "peek" in to the next line, and if it starts with a special character I want to break out of a for loop, other wise I want to do readline(). Is there a way to do this? for example: while 1: line=stdin.peek_nextline()
2
8503
by: Eddy | last post by:
I have a big problem with streamreader ReadLine()! I read from a long text files about 13k lines, than I encounter a problem: ReadLine() is not anymore able to go on! I have a string whose name is riga, where I put the return value of Readline(), and this is what happens, when I read these three lines: 106933;;rosso;ivan mauricio;3347614603;trak15@yahoo.com;1984-06-04;M;;;milano;CO;politecnico # ingegneria;;;...
1
1450
by: t4zone58 | last post by:
Hi Basically I am print out a group of number with a certain increment. However I found out a wierd thing happened from the result The code I wrote: Dim number1, number2, counter, increment As Double Console.Write("Enter number1:") number1 = Console.ReadLine Console.Write("Enter number2:") number2=...
5
3436
by: rodchar | last post by:
hey all, i'm trying to read a text document line by line into a stringbuilder and an issue i'm running into is this: do while streamReader.ReadLine stringBuilder.Append("my string" & string.ReadLine) is showing up like this: "my string" value instead of
4
1532
by: Vernon Wenberg III | last post by:
I'm not really sure how readline() works. Is there a way to iterate through a file with multiple lines and then putting each line in a variable in a loop?
5
2727
by: kj | last post by:
I'm trying to subclass file, overriding the readline method. The new method definition begins with def readline(self, size=None): line = self.file.readline(size) # etc., etc. ....where the self.file attribute is a regular file object. This works fine if I invoke the new method with an integer argument,
0
2460
by: Akira Kitada | last post by:
Hi list, I was trying to build Python 2.6 on FreeBSD 4.11 and found it failed to build some of the modules. """ Failed to find the necessary bits to build these modules: _bsddb _sqlite3 _tkinter gdbm linuxaudiodev spwd sunaudiodev
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10435
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10213
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.