Click here to Skip to main content
14,454,577 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: Serial downvoting Pin
Nelek31-Oct-19 3:10
protectorNelek31-Oct-19 3:10 
GeneralRe: Serial downvoting Pin
Gary Wheeler31-Oct-19 7:42
MemberGary Wheeler31-Oct-19 7:42 
PraiseRe: Serial downvoting Pin
RickZeeland31-Oct-19 9:45
communityengineerRickZeeland31-Oct-19 9:45 
GeneralRe: Serial downvoting Pin
Gary Wheeler31-Oct-19 9:48
MemberGary Wheeler31-Oct-19 9:48 
GeneralRe: Serial downvoting Pin
Member 1459627731-Oct-19 19:37
MemberMember 1459627731-Oct-19 19:37 
GeneralRe: Serial downvoting Pin
RickZeeland31-Oct-19 21:51
communityengineerRickZeeland31-Oct-19 21:51 
GeneralRe: Serial downvoting Pin
Member 1459627731-Oct-19 22:10
MemberMember 1459627731-Oct-19 22:10 
GeneralRe: Serial downvoting Pin
RickZeeland31-Oct-19 22:38
communityengineerRickZeeland31-Oct-19 22:38 
For some reason I can't post a solution, so I will put it here:

Here is a simple example to get you started, it prints the line numbers and the text of the lines:
this.FindWords("test.txt", "private");

private void FindWords(string fileName, string searchString)
{
    string line;
    int count = 1;

    using (TextReader reader = File.OpenText(fileName))
    {
        while ((line = reader.ReadLine()) != null)
        {
            if (line.Contains(searchString))
            {
                Console.WriteLine(count + " " + line);
            }

            count++;
        }
    }
}

It would be a good idea to improve this with Regex search expressions, here is a nice Regex example (don't fear it aims to take away the complexity of Regex):
Converting Wildcards to Regexes[^]
GeneralRe: Serial downvoting Pin
Member 145962771-Nov-19 14:17
MemberMember 145962771-Nov-19 14:17 
GeneralRe: Serial downvoting Pin
dandy7231-Oct-19 10:35
Memberdandy7231-Oct-19 10:35 
GeneralRe: Serial downvoting Pin
RickZeeland31-Oct-19 10:49
communityengineerRickZeeland31-Oct-19 10:49 
GeneralThursday...Never could get hang of them... Pin
glennPattonWork30-Oct-19 23:29
professionalglennPattonWork30-Oct-19 23:29 
GeneralRe: Thursday...Never could get hang of them... Pin
RickZeeland31-Oct-19 0:28
communityengineerRickZeeland31-Oct-19 0:28 
GeneralRe: Thursday...Never could get hang of them... Pin
dandy7231-Oct-19 10:00
Memberdandy7231-Oct-19 10:00 
GeneralWSO - CCC 31/10/2019 - Unthemed Pin
Abbas A. Ali30-Oct-19 23:07
professionalAbbas A. Ali30-Oct-19 23:07 
GeneralRe: WSO - CCC 31/10/2019 - Unthemed Pin
pkfox31-Oct-19 0:18
professionalpkfox31-Oct-19 0:18 
GeneralRe: WSO - CCC 31/10/2019 - Unthemed Pin
Abbas A. Ali31-Oct-19 0:21
professionalAbbas A. Ali31-Oct-19 0:21 
GeneralWorking with... mm... rather average programmer.... Pin
Super Lloyd30-Oct-19 19:01
MemberSuper Lloyd30-Oct-19 19:01 
GeneralRe: Working with... mm... rather average programmer.... Pin
KarstenK30-Oct-19 22:07
mveKarstenK30-Oct-19 22:07 
GeneralRe: Working with... mm... rather average programmer.... Pin
Daniel Pfeffer30-Oct-19 22:17
professionalDaniel Pfeffer30-Oct-19 22:17 
GeneralRe: Working with... mm... rather average programmer.... Pin
KarstenK31-Oct-19 5:18
mveKarstenK31-Oct-19 5:18 
GeneralRe: Working with... mm... rather average programmer.... Pin
CPallini30-Oct-19 22:49
mveCPallini30-Oct-19 22:49 
GeneralRe: Working with... mm... rather average programmer.... Pin
RickZeeland30-Oct-19 22:55
communityengineerRickZeeland30-Oct-19 22:55 
GeneralRe: Working with... mm... rather average programmer.... Pin
Super Lloyd31-Oct-19 3:46
MemberSuper Lloyd31-Oct-19 3:46 
GeneralRe: Working with... mm... rather average programmer.... Pin
  Forogar  31-Oct-19 4:29
professional  Forogar  31-Oct-19 4:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.