18 Replies - 1885 Views - Last Post: 20 December 2011 - 08:05 PM
#1
split text file into lines on C#?
Posted 19 December 2011 - 12:06 PM
Please could you help me with this as this one area i am struggling with.
thanks
Simon
Replies To: split text file into lines on C#?
#2
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:13 PM
#3
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:20 PM
#4
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:25 PM
Stream reader & readline.
http://msdn.microsof...reamreader.aspx
You should be able to declare an array of strings alright, right?
#5
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:27 PM
#6
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:30 PM
Il give it a shot1
#7
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:50 PM
I've got an object that read from a file. Tick
Does that object provide a way of reading a line. Tick
So let me think what do put each line into an array?
Is it me? Or is Dream.In.Code attracting more and more lazy-assed people, that want to play at being toy programmers? OK here's the deal, I don't want to be bothered doing the thinking part. So give me the "money" (Code).
Put it this way. If they want to get their hands on some money without the effort of making it.
It's like they are walking and browsing down the street, and spot a bank (Dream.In.Code). They've got loads of money, I'll "use" theirs.
"Hello {Insert Cashier Name}, would you be awful kind and put the contents of your cash drawer in this bag since my funds are running a little short. Thank You.". And the Cashier actually doing it.
This post has been edited by AdamSpeight2008: 19 December 2011 - 12:56 PM
#8
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:53 PM
Oh, and if I am not mistaken this typical homework assignment is used to teach loops and the streamreader. Trying to short circuit everything with "File.ReadlAllLines" bypasses that specific area.
Edit:ah it looks like Adam covered my second thought!
#9
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:53 PM
#10
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:54 PM
#11
Re: split text file into lines on C#?
Posted 19 December 2011 - 12:55 PM
#12
Re: split text file into lines on C#?
Posted 19 December 2011 - 02:55 PM
This post has been edited by tlhIn`toq: 19 December 2011 - 02:58 PM
#13
Re: split text file into lines on C#?
Posted 20 December 2011 - 06:49 AM
modi123_1, on 19 December 2011 - 12:53 PM, said:
Oh, and if I am not mistaken this typical homework assignment is used to teach loops and the streamreader. Trying to short circuit everything with "File.ReadlAllLines" bypasses that specific area.
Edit:ah it looks like Adam covered my second thought!
Care to point out where Simon-Thomas has stated this is homework?
I'm aware of basic rules of the forum. But I'm also aware that to start to learn programming you need examples, that's why MSDN has the examples there, however they do not for the ReadAllLines method.
Yes that's most likely because of how simple the method is, but so is the iteration of getting each line on a text document, so if a user is asking how to do it, most likely they will not understand how "signatures" work, I know this because I've helped teach a Java programming class and one thing all the people new to programming struggled with was "objects" and "signature" definitions (along with such things as UML).
#14
Re: split text file into lines on C#?
Posted 20 December 2011 - 07:19 AM
OK! Then give an example that isn't the code that he has to figure out.
Give the example of some general syntax and implementation for the given class, but not related to the current topic. Then the OP will figure out what he needs to do from there and do it.
This is so that the OP will actually learn instead of copying and pasting in your code. That way he won't know what it does neither how it does it, he just uses it because it works.
Following that curve he won't be able to learn advanced topics that rely on the basics like this. It's by giving him explicit code you actually harm him, not help him. That's why there is homework in the first place. Homework are given so that the students can learn something (or to better understand the already learned things).
Also if the OP doesn't understand something that is used for a basis for this topic then refer him to some documentation where he can learn about that and then advance. Not just rush in-head on and when he sees that the door is thick and hard get a concussion. It's also because of that why we don't give finished code.
You can't discuss advanced topics if you didn't learn the basics! Period.
This post has been edited by RexGrammer: 20 December 2011 - 07:26 AM
#15
Re: split text file into lines on C#?
Posted 20 December 2011 - 07:43 AM
racidon, on 20 December 2011 - 09:49 AM, said:
modi123_1, on 19 December 2011 - 12:53 PM, said:
Oh, and if I am not mistaken this typical homework assignment is used to teach loops and the streamreader. Trying to short circuit everything with "File.ReadlAllLines" bypasses that specific area.
Edit:ah it looks like Adam covered my second thought!
Care to point out where Simon-Thomas has stated this is homework?
Use this rule-of-thumb: If the member has 1 post, the default profile image, ask a question about how to do something and post no code, then 99% of the time they are a student and are asking for you to do their homework for them.
For the most part, the poster is not going to say, "Can you help with my homework?", because the post box actually states that we will not do their homework for them. So using the logic, "Well he didn't say it was homework" is naive.
Many of us have been here long enough to be able to spot members who are here solely for us to do their homework for them.
Have you noticed how Simon-Thomas has not denied that this is for homework? He's read us saying it's for his homework, and he has not denied it. That should tell you something.
|
|

New Topic/Question
Reply



MultiQuote











|