Click here to Skip to main content
15,888,521 members
Home / Discussions / C#
   

C#

 
AnswerRe: Passing Json from Winforms to console app for writing to file Pin
jkirkerx31-Jan-19 10:18
professionaljkirkerx31-Jan-19 10:18 
AnswerRe: Passing Json from Winforms to console app for writing to file Pin
Dave Kreskowiak31-Jan-19 13:52
mveDave Kreskowiak31-Jan-19 13:52 
GeneralRe: Passing Json from Winforms to console app for writing to file Pin
jkirkerx1-Feb-19 7:50
professionaljkirkerx1-Feb-19 7:50 
QuestionC# MongoDB Guid Problem Pin
Kevin Marois31-Jan-19 7:49
professionalKevin Marois31-Jan-19 7:49 
AnswerRe: C# MongoDB Guid Problem Pin
BillWoodruff31-Jan-19 12:26
professionalBillWoodruff31-Jan-19 12:26 
AnswerRe: C# MongoDB Guid Problem Pin
Richard Deeming1-Feb-19 1:12
mveRichard Deeming1-Feb-19 1:12 
QuestionExtracting string between quotes Pin
Priya Karthish31-Jan-19 0:08
Priya Karthish31-Jan-19 0:08 
AnswerRe: Extracting string between quotes Pin
lmoelleb31-Jan-19 0:23
lmoelleb31-Jan-19 0:23 
Learn go debug - it is simple to learn and it will save you a LOT of time.

The first you can do is split the program out over multiple lines so it is easier to read and debug.

So instead of
string sub = line.Substring(line.IndexOf("<a name=") , line.Length - line.IndexOf("<a name=") - 6);


you can do something like:
string line = "<p class=\"rvps5\"><a name=\"4980_YM\"></a>";
int startPosition = line.IndexOf("<a name=");
if (startPosition >= 0)
{
    int length = line.Length - startPosition - 6;
    string substring = line.Substring(startPosition, length);
    Console.WriteLine(substring);
}


Now set a breakpoint and step through each line. Inspect the variables as they are assigned to ensure they are the correct value. Once you do this, it will be evident that the startPosition is wrong, and the length does not match the length of the string. You will make mistakes like this ALL the time - we all do. Once you structure your code so it does less at once and spend 10 minutes learning debugging, you will fix errors like this in a few seconds.

In general parsing HTML is somewhat tricky to get right, and covering all different ways the same text can be represented is extremely difficult - but if your source text is consistent you should be able to get it working with this method.
AnswerRe: Extracting string between quotes Pin
OriginalGriff31-Jan-19 0:53
mveOriginalGriff31-Jan-19 0:53 
JokeRe: Extracting string between quotes Pin
Richard Deeming1-Feb-19 1:08
mveRichard Deeming1-Feb-19 1:08 
AnswerRe: Extracting string between quotes Pin
AFell231-Jan-19 5:35
AFell231-Jan-19 5:35 
QuestionC# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx30-Jan-19 9:54
professionaljkirkerx30-Jan-19 9:54 
AnswerMy Bad! Pin
jkirkerx30-Jan-19 11:32
professionaljkirkerx30-Jan-19 11:32 
GeneralRe: My Bad! Pin
OriginalGriff30-Jan-19 21:20
mveOriginalGriff30-Jan-19 21:20 
GeneralRe: My Bad! Pin
jkirkerx1-Feb-19 7:45
professionaljkirkerx1-Feb-19 7:45 
AnswerRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
Eddy Vluggen1-Feb-19 2:12
professionalEddy Vluggen1-Feb-19 2:12 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx1-Feb-19 7:48
professionaljkirkerx1-Feb-19 7:48 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
Eddy Vluggen1-Feb-19 8:39
professionalEddy Vluggen1-Feb-19 8:39 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx1-Feb-19 8:44
professionaljkirkerx1-Feb-19 8:44 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
Eddy Vluggen1-Feb-19 9:29
professionalEddy Vluggen1-Feb-19 9:29 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx1-Feb-19 9:39
professionaljkirkerx1-Feb-19 9:39 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
Eddy Vluggen1-Feb-19 10:56
professionalEddy Vluggen1-Feb-19 10:56 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx1-Feb-19 11:15
professionaljkirkerx1-Feb-19 11:15 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
Eddy Vluggen1-Feb-19 11:20
professionalEddy Vluggen1-Feb-19 11:20 
GeneralRe: C# Winforms, Installation Folder Permission, parameter settings file is always admin read/write, user read only Pin
jkirkerx1-Feb-19 11:28
professionaljkirkerx1-Feb-19 11:28 

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.