Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
AnswerRe: Send data toServer with two parameters Pin
Carmen_Mundi19-Apr-18 5:55
Carmen_Mundi19-Apr-18 5:55 
GeneralRe: Send data toServer with two parameters Pin
Richard MacCutchan19-Apr-18 6:13
mveRichard MacCutchan19-Apr-18 6:13 
GeneralRe: Send data toServer with two parameters Pin
Carmen_Mundi19-Apr-18 7:37
Carmen_Mundi19-Apr-18 7:37 
GeneralRe: Send data toServer with two parameters Pin
Richard MacCutchan19-Apr-18 21:53
mveRichard MacCutchan19-Apr-18 21:53 
QuestionReading a specific portion of a text file Pin
Member 1377871518-Apr-18 4:42
Member 1377871518-Apr-18 4:42 
AnswerRe: Reading a specific portion of a text file Pin
OriginalGriff18-Apr-18 4:59
mveOriginalGriff18-Apr-18 4:59 
GeneralRe: Reading a specific portion of a text file Pin
Member 1377871518-Apr-18 7:34
Member 1377871518-Apr-18 7:34 
GeneralRe: Reading a specific portion of a text file Pin
OriginalGriff18-Apr-18 8:16
mveOriginalGriff18-Apr-18 8:16 
So your data is stored as
Employee Name: John smith Junior 1234 20000.00 36
That's a bad idea - it makes it very difficult to read back, particularly since you are passing user input direct to the output file. You don't check what the user entered and have no idea if the data you write is correct!

So there are two things to do:
1) Validate your inputs!
If the user should enter a number, check it is a valid number:
C#
double pay;
if (!double.TryParse(txtPay.Text, out pay))
   {
   ... report problem to user
   return;
   }
And the same for all other non-text values.
Text values are another problem, and that leads to:
2) Structure your file! When you separate with spaces, it's very difficult to work out what is what: did the user type the name as
John
John Smith
John Smith Junior
Charles Philip Arthur George Mountbatten-Windsor
When your separator is the same as a legitimate name character you leave yourself a lot of problems.
There are a number of ways to deal with that, in order of effectiveness and complexity:
2a) Move the variable length entry (the name) to the end of the line. That way, it doesn't matter how long it is!
2b) Use an "special character" as the field separator: comma is a good one, as is '|'
2c) Delimit text strings, and use a special character:
"John",
"John Smith",
"John Smith Junior",
"Charles Philip Arthur George Mountbatten-Windsor",

2d) Use a "proper" CSV data system - there are some good ones out there: A Fast CSV Reader[^] works well.
2e) Use a structured data file: XML or JSON are both excellent and widely supported.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

GeneralRe: Reading a specific portion of a text file Pin
Member 1377871518-Apr-18 11:29
Member 1377871518-Apr-18 11:29 
AnswerRe: Reading a specific portion of a text file Pin
Gerry Schmitz18-Apr-18 5:54
mveGerry Schmitz18-Apr-18 5:54 
QuestionManagementScope, did it get deprecated or something? Pin
Robert Oujesky18-Apr-18 4:38
Robert Oujesky18-Apr-18 4:38 
AnswerRe: ManagementScope, did it get deprecated or something? Pin
OriginalGriff18-Apr-18 5:03
mveOriginalGriff18-Apr-18 5:03 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
Eddy Vluggen18-Apr-18 6:01
professionalEddy Vluggen18-Apr-18 6:01 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
OriginalGriff18-Apr-18 6:25
mveOriginalGriff18-Apr-18 6:25 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
Robert Oujesky18-Apr-18 6:25
Robert Oujesky18-Apr-18 6:25 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
OriginalGriff18-Apr-18 6:29
mveOriginalGriff18-Apr-18 6:29 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
Robert Oujesky18-Apr-18 6:41
Robert Oujesky18-Apr-18 6:41 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
Eddy Vluggen18-Apr-18 7:10
professionalEddy Vluggen18-Apr-18 7:10 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
OriginalGriff18-Apr-18 8:02
mveOriginalGriff18-Apr-18 8:02 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
Robert Oujesky18-Apr-18 8:49
Robert Oujesky18-Apr-18 8:49 
GeneralRe: ManagementScope, did it get deprecated or something? Pin
OriginalGriff18-Apr-18 9:15
mveOriginalGriff18-Apr-18 9:15 
QuestionHow can I add the distance value between the line(from point A to point B) in C#? Pin
Member 1378306217-Apr-18 22:27
Member 1378306217-Apr-18 22:27 
AnswerRe: How can I add the distance value between the line(from point A to point B) in C#? Pin
OriginalGriff17-Apr-18 22:35
mveOriginalGriff17-Apr-18 22:35 
AnswerRe: How can I add the distance value between the line(from point A to point B) in C#? Pin
V.17-Apr-18 23:56
professionalV.17-Apr-18 23:56 
AnswerRe: How can I add the distance value between the line(from point A to point B) in C#? Pin
Gerry Schmitz18-Apr-18 6:03
mveGerry Schmitz18-Apr-18 6:03 

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.