Click here to Skip to main content
15,908,444 members
Home / Discussions / C#
   

C#

 
AnswerRe: Get value from string and pass it to another field Pin
Dave Kreskowiak30-Aug-16 13:17
mveDave Kreskowiak30-Aug-16 13:17 
So much wrong, where do I begin...

First, a caveat. There is not enough code he to get a complete picture of what you're doing and how you're using this code.

You're using a property incorrectly. You're using it as essentially a readonly property and a method to try and parse an input. I'd probably break this into a REAL readonly property with only a getter and then a method to parse the input and set the property backing field. You're not using the value supplied by the property settor.

The backing field I would probably rename to _selos to make sure its differentiated from all other mentions of it in the code.

The method to parse the input would probably be easier with a regular expression instead of using the "magic values" and very nainve method you're using. What if the comment contains "sEro:"? It's going to fail. Use a case-insensitive check instead.

Also, when you split the Comment string you're using the first element in the resulting string array, which is always going to be to first word in the Comment, in your example it's "Everything".

Free form user input is not the best idea. If you can avoid it, do so. If not, treat it like it's out to destroy the world. Don't trust it to contain anything usable at all and if it does, don't trust it to be in a format you can easily parse.
A guide to posting questions on CodeProject

Click this: Asking questions is a skill.
Seriously, do it.

Dave Kreskowiak

Questionobject reference not set to an instance of an object Pin
mmiklauz29-Aug-16 6:38
mmiklauz29-Aug-16 6:38 
AnswerRe: object reference not set to an instance of an object Pin
Pete O'Hanlon29-Aug-16 7:23
mvePete O'Hanlon29-Aug-16 7:23 
AnswerRe: object reference not set to an instance of an object PinPopular
OriginalGriff29-Aug-16 8:05
mveOriginalGriff29-Aug-16 8:05 
AnswerRe: object reference not set to an instance of an object Pin
Abhinav S29-Aug-16 18:36
Abhinav S29-Aug-16 18:36 
QuestionHow to show results based on rdo button selected without having to re-access database? Pin
kmllev29-Aug-16 5:10
kmllev29-Aug-16 5:10 
AnswerRe: How to show results based on rdo button selected without having to re-access database? Pin
Gerry Schmitz29-Aug-16 10:21
mveGerry Schmitz29-Aug-16 10:21 
GeneralRe: How to show results based on rdo button selected without having to re-access database? Pin
kmllev29-Aug-16 17:46
kmllev29-Aug-16 17:46 
Question5.5.1 Authentication Required Pin
Member 1270877429-Aug-16 0:34
Member 1270877429-Aug-16 0:34 
AnswerRe: 5.5.1 Authentication Required Pin
OriginalGriff29-Aug-16 0:45
mveOriginalGriff29-Aug-16 0:45 
QuestionHow to change background color of RadGridView? Pin
Daniyaltjm28-Aug-16 23:34
Daniyaltjm28-Aug-16 23:34 
AnswerRe: How to change background color of RadGridView? Pin
#realJSOP31-Aug-16 3:26
professional#realJSOP31-Aug-16 3:26 
GeneralRe: How to change background color of RadGridView? Pin
Daniyaltjm31-Aug-16 6:52
Daniyaltjm31-Aug-16 6:52 
Questionhow set custom paper size on printer setting? Pin
Le@rner26-Aug-16 18:34
Le@rner26-Aug-16 18:34 
AnswerRe: how set custom paper size on printer setting? Pin
Richard MacCutchan26-Aug-16 21:01
mveRichard MacCutchan26-Aug-16 21:01 
GeneralRe: how set custom paper size on printer setting? Pin
Le@rner26-Aug-16 21:31
Le@rner26-Aug-16 21:31 
GeneralRe: how set custom paper size on printer setting? Pin
Richard MacCutchan26-Aug-16 21:52
mveRichard MacCutchan26-Aug-16 21:52 
QuestionJoin Main Thread in a Console Application Pin
Member 1270567426-Aug-16 13:25
Member 1270567426-Aug-16 13:25 
AnswerRe: Join Main Thread in a Console Application Pin
Garth J Lancaster26-Aug-16 18:36
professionalGarth J Lancaster26-Aug-16 18:36 
AnswerRe: Join Main Thread in a Console Application Pin
Eddy Vluggen29-Aug-16 4:19
professionalEddy Vluggen29-Aug-16 4:19 
Questionreg Pin
mbatra3125-Aug-16 23:01
mbatra3125-Aug-16 23:01 
AnswerRe: How to Parse .XFDL files in C#.? Pin
OriginalGriff25-Aug-16 23:06
mveOriginalGriff25-Aug-16 23:06 
GeneralMessage Closed Pin
25-Aug-16 23:15
mbatra3125-Aug-16 23:15 
GeneralRe: How to Parse .XFDL files in C#.? Pin
OriginalGriff25-Aug-16 23:23
mveOriginalGriff25-Aug-16 23:23 
GeneralRe: How to Parse .XFDL files in C#.? Pin
Richard MacCutchan26-Aug-16 0:06
mveRichard MacCutchan26-Aug-16 0:06 

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.