Click here to Skip to main content
15,923,120 members
Home / Discussions / C#
   

C#

 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
Member 1289974625-Dec-16 21:21
Member 1289974625-Dec-16 21:21 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
OriginalGriff25-Dec-16 21:33
mveOriginalGriff25-Dec-16 21:33 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
Member 1289974625-Dec-16 21:37
Member 1289974625-Dec-16 21:37 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
OriginalGriff25-Dec-16 21:49
mveOriginalGriff25-Dec-16 21:49 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
Member 1289974625-Dec-16 21:59
Member 1289974625-Dec-16 21:59 
GeneralRe: I'm get confusing and A state of mental distractions I can not understand the error.....code bellow...for trans data from sql database to another Pin
OriginalGriff25-Dec-16 22:00
mveOriginalGriff25-Dec-16 22:00 
GeneralRe:I can not understand the error.....code bellow...for trans data from sql database to another Pin
Member 1289974625-Dec-16 22:46
Member 1289974625-Dec-16 22:46 
GeneralRe:I can not understand the error.....code bellow...for trans data from sql database to another Pin
OriginalGriff25-Dec-16 23:00
mveOriginalGriff25-Dec-16 23:00 
GeneralRe:I can not understand the error.....code bellow...for trans data from sql database to another Pin
Member 1289974625-Dec-16 23:24
Member 1289974625-Dec-16 23:24 
GeneralRe:I can not understand the error.....code bellow...for trans data from sql database to another Pin
OriginalGriff25-Dec-16 23:41
mveOriginalGriff25-Dec-16 23:41 
GeneralRe: I can not understand the error.....code bellow...for trans data from sql database to another Pin
Gerry Schmitz26-Dec-16 6:01
mveGerry Schmitz26-Dec-16 6:01 
QuestionThe programming webcam with Visual Studio standard library ? Pin
Member 245846725-Dec-16 19:42
Member 245846725-Dec-16 19:42 
AnswerRe: The programming webcam with Visual Studio standard library ? Pin
Richard MacCutchan25-Dec-16 20:38
mveRichard MacCutchan25-Dec-16 20:38 
GeneralRe: The programming webcam with Visual Studio standard library ? Pin
Member 245846728-Dec-16 15:51
Member 245846728-Dec-16 15:51 
QuestionC# Database Question and Answers Connect Pin
Pavlex425-Dec-16 3:36
Pavlex425-Dec-16 3:36 
AnswerRe: C# Database Question and Answers Connect Pin
Richard Andrew x6425-Dec-16 5:24
professionalRichard Andrew x6425-Dec-16 5:24 
GeneralRe: C# Database Question and Answers Connect Pin
Pavlex425-Dec-16 7:02
Pavlex425-Dec-16 7:02 
GeneralRe: C# Database Question and Answers Connect Pin
Pete O'Hanlon25-Dec-16 9:57
mvePete O'Hanlon25-Dec-16 9:57 
GeneralRe: C# Database Question and Answers Connect Pin
Pavlex426-Dec-16 7:39
Pavlex426-Dec-16 7:39 
GeneralRe: C# Database Question and Answers Connect Pin
Pete O'Hanlon27-Dec-16 22:24
mvePete O'Hanlon27-Dec-16 22:24 
QuestionC# Read from text file Pin
Pavlex423-Dec-16 21:16
Pavlex423-Dec-16 21:16 
AnswerRe: C# Read from text file Pin
Michael_Davies23-Dec-16 21:29
Michael_Davies23-Dec-16 21:29 
AnswerRe: C# Read from text file Pin
OriginalGriff23-Dec-16 21:34
mveOriginalGriff23-Dec-16 21:34 
GeneralRe: C# Read from text file Pin
Pavlex423-Dec-16 21:40
Pavlex423-Dec-16 21:40 
AnswerRe: C# Read from text file Pin
Midi_Mick23-Dec-16 21:41
professionalMidi_Mick23-Dec-16 21:41 
StartsWith and EndsWith perform no operations on the strings themselves - they are simply boolean methods that return true or false based on what the string Starts or Ends with - so your code will return no results.

Instead, you need to perform a "Select", and extract the part of the string you require. Two possible methods come to mind immediately:
C#
File.ReadLines(path).Select(x=>x.SubString(1, x.IndexOf("?")-1).ToList();

or
C#
File.ReadLines(path).Select(x=>x.Split(new char[]{'[','?'}, StringSplitOption.RemoveEmptyEntries)[0]).ToList();

You could also look at using Regex, but I think it might be a bit of overkill for this case.
Cheers,

Mick
------------------------------------------------
It doesn't matter how often or hard you fall on your arse, eventually you'll roll over and land on your feet.

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.