Hello, I've started with C# and need help.
I have to count the paragraphs in a textfile, but i'm failing.
::name.txt
sometext
sometext
sometextsometext
sometext
sometextsometext
sometext
--ENDIn this example I have 3 paragraphs, but how do I count it?
It should look to the newline to recover what is a new paragraph, if u know what I mean.
All help is welcome,
Regards,
Happy is ONE who says I am an OttoMAN.
Just search through the characters of the file to find pairs of CR/LFs.
Hello ijack, Thank-you for your fast reply.
But I dont know how I can do that, maybe you can show me?
Regards,
Happy is ONE who says I am an OttoMAN.
Read the file into a string; iterate through the characters in the string. Either this is a homework question or you are trying to learn C# by yourself. In either event you will learn more by doing a little research than by copying an answer parrot fashion, so I'm not going to give a more detailed reply.
Before argumenting this is homework or not, I have tried this for 1 hour atm, searched on the internet and could not find an proper answer.
Thats why I'm posting here, cuz I cant continue..Happy is ONE who says I am an OttoMAN.
Well, I think you need to brush up on your search skills. Google "C# read text file". The first hit will give you the answer, together with an example, of how to read a text file into a string. Now the rest is up to you - it is clear from your answer that this is homework and I have no intention of doing it for you.
Yes (14) | ![]() | |
No (14) | ![]() | |
I don't know (15) | ![]() |