Click here to Skip to main content
15,886,873 members
Home / Discussions / C#
   

C#

 
GeneralRe: I need help improving my code Pin
Gilbert Consellado5-Nov-15 23:42
professionalGilbert Consellado5-Nov-15 23:42 
GeneralRe: I need help improving my code Pin
BillWoodruff6-Nov-15 0:42
professionalBillWoodruff6-Nov-15 0:42 
GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 2:17
professionalGilbert Consellado6-Nov-15 2:17 
GeneralRe: I need help improving my code Pin
BillWoodruff6-Nov-15 2:40
professionalBillWoodruff6-Nov-15 2:40 
GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 3:00
professionalGilbert Consellado6-Nov-15 3:00 
GeneralRe: I need help improving my code Pin
BillWoodruff6-Nov-15 4:14
professionalBillWoodruff6-Nov-15 4:14 
GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 4:45
professionalGilbert Consellado6-Nov-15 4:45 
AnswerRe: I need help improving my code Pin
V.5-Nov-15 19:52
professionalV.5-Nov-15 19:52 
There are a few things you can do. BillWoodRuff gave a good example.
  • the control variable is never used inside the function.
  • Is there a reason to pass value as an object? In addition I would never use a keyword (value) as a variable name. (unless the autofill gave it that name of course)
  • I never program multiple exit points in a function, often it is harder to debug. Better to set a boolean and return that at the end. (although that's more a matter of taste)
  • Keep the { }. It will be easier to add a statement if a modification is needed.
  • int.TryParse is a very good function. I also often use Convert.ToInt32, but make sure you know what it returns in case of null values or invalid integer strings/objects. (read MSDN doc)
  • In some countries the decimal sign is not a ".", but a komma ",".
  • You don't need _minValue or _maxValue you have int.MinValue and int.MaxValue.
  • An object variable has an IsNumber() and ToInt() function? (not in version 4.5)
Hope this helps.
V.

(MQOTD rules and previous solutions)

GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 0:04
professionalGilbert Consellado6-Nov-15 0:04 
AnswerRe: I need help improving my code Pin
Chris Quinn5-Nov-15 22:14
Chris Quinn5-Nov-15 22:14 
GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 0:08
professionalGilbert Consellado6-Nov-15 0:08 
AnswerRe: I need help improving my code Pin
Rob Philpott5-Nov-15 23:03
Rob Philpott5-Nov-15 23:03 
GeneralRe: I need help improving my code Pin
Gilbert Consellado6-Nov-15 0:12
professionalGilbert Consellado6-Nov-15 0:12 
Questionwhy you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
BillWoodruff4-Nov-15 23:25
professionalBillWoodruff4-Nov-15 23:25 
AnswerRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
Eddy Vluggen4-Nov-15 23:42
professionalEddy Vluggen4-Nov-15 23:42 
GeneralRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
BillWoodruff5-Nov-15 4:44
professionalBillWoodruff5-Nov-15 4:44 
GeneralRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
Eddy Vluggen5-Nov-15 8:28
professionalEddy Vluggen5-Nov-15 8:28 
AnswerRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? PinPopular
Pete O'Hanlon5-Nov-15 0:55
mvePete O'Hanlon5-Nov-15 0:55 
GeneralRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
BillWoodruff5-Nov-15 4:46
professionalBillWoodruff5-Nov-15 4:46 
GeneralRe: why you cannot "spoof" an Interface to use to cast an Object to a Type you know the structure of ? Pin
Pete O'Hanlon5-Nov-15 5:07
mvePete O'Hanlon5-Nov-15 5:07 
QuestionOAUTH2 Access from .NET Console/WinForms Pin
Member 119360464-Nov-15 22:43
Member 119360464-Nov-15 22:43 
AnswerRe: OAUTH2 Access from .NET Console/WinForms Pin
Dave Kreskowiak5-Nov-15 6:23
mveDave Kreskowiak5-Nov-15 6:23 
Questionevery email is ok,even email address is like that(sdfsdfsdf@gmail.com ) Pin
Member 118929084-Nov-15 20:32
Member 118929084-Nov-15 20:32 
AnswerRe: every email is ok,even email address is like that(sdfsdfsdf@gmail.com ) Pin
John Torjo4-Nov-15 20:52
professionalJohn Torjo4-Nov-15 20:52 
AnswerRe: every email is ok,even email address is like that(sdfsdfsdf@gmail.com ) Pin
OriginalGriff4-Nov-15 21:10
mveOriginalGriff4-Nov-15 21:10 

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.