Click here to Skip to main content
15,889,281 members
Home / Discussions / C#
   

C#

 
AnswerRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 6:08
harold aptroot2-Apr-09 6:08 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
bbranded2-Apr-09 7:06
bbranded2-Apr-09 7:06 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 8:19
harold aptroot2-Apr-09 8:19 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
Luc Pattyn2-Apr-09 8:53
sitebuilderLuc Pattyn2-Apr-09 8:53 
GeneralRe: An easy one... problems converting a decimal to an integer Pin
harold aptroot2-Apr-09 9:11
harold aptroot2-Apr-09 9:11 
AnswerRe: An easy one... problems converting a decimal to an integer Pin
Luc Pattyn2-Apr-09 8:58
sitebuilderLuc Pattyn2-Apr-09 8:58 
Question1st Post and Code snip so far Pin
stonebergftw2-Apr-09 5:03
stonebergftw2-Apr-09 5:03 
AnswerRe: 1st Post and Code snip so far Pin
Judah Gabriel Himango2-Apr-09 5:45
sponsorJudah Gabriel Himango2-Apr-09 5:45 
Overall, it looks pretty good, especially for a beginner. I've seen worse code in production.

Couple thoughts:

Don't use ArrayList. That's old .NET 1.0 junk that boxes every value type you put in it (thus making more memory allocations). It makes your code uglier because when pulling values out, you have to cast it to the correct type. It makes your code more prone to error because you can put other objects besides longs in it.

Since you're just putting VIN#s of type long in that list, use a List<long> instead. The compiler will make sure you don't put anything besides longs in it, it performs better than ArrayList, your code will be cleaner, no boxing required.

Another thought related to int.Parse. int.Parse is OK, however, you should be aware of TryParse alternative method. TryParse won't throw an exception, and will return a value indicating whether the parse was successful:

int value;
bool successfullyParsed = int.TryParse("123", out value);
if (successfullyParsed)
{
    // Use value here.
}


Since exceptions are costly, you may want to consider TryParse instead of Parse if that fits your code OK. If Parse fits better, feel free to continue using it.



Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango



GeneralRe: 1st Post and Code snip so far Pin
stonebergftw2-Apr-09 6:02
stonebergftw2-Apr-09 6:02 
GeneralRe: 1st Post and Code snip so far Pin
Judah Gabriel Himango2-Apr-09 6:04
sponsorJudah Gabriel Himango2-Apr-09 6:04 
AnswerRe: 1st Post and Code snip so far Pin
Simon P Stevens2-Apr-09 5:52
Simon P Stevens2-Apr-09 5:52 
GeneralRe: 1st Post and Code snip so far Pin
stonebergftw2-Apr-09 6:44
stonebergftw2-Apr-09 6:44 
GeneralRe: 1st Post and Code snip so far Pin
Simon P Stevens2-Apr-09 21:20
Simon P Stevens2-Apr-09 21:20 
GeneralRe: 1st Post and Code snip so far Pin
stonebergftw6-Apr-09 7:29
stonebergftw6-Apr-09 7:29 
QuestionVisualizing Windows Form interactively!!!! Pin
Rajdeep.NET is BACK2-Apr-09 4:57
Rajdeep.NET is BACK2-Apr-09 4:57 
QuestionRe: Visualizing Windows Form interactively!!!! Pin
led mike2-Apr-09 5:02
led mike2-Apr-09 5:02 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Rajdeep.NET is BACK2-Apr-09 5:13
Rajdeep.NET is BACK2-Apr-09 5:13 
GeneralRe: Visualizing Windows Form interactively!!!! Pin
led mike2-Apr-09 5:41
led mike2-Apr-09 5:41 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Alok Sharma ji2-Apr-09 12:38
Alok Sharma ji2-Apr-09 12:38 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
DaveyM692-Apr-09 5:26
professionalDaveyM692-Apr-09 5:26 
AnswerRe: Visualizing Windows Form interactively!!!! Pin
Alok Sharma ji3-Apr-09 6:57
Alok Sharma ji3-Apr-09 6:57 
QuestionDatagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid [modified] Pin
Priya Prk2-Apr-09 4:37
Priya Prk2-Apr-09 4:37 
AnswerRe: Datagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid Pin
Rajdeep.NET is BACK2-Apr-09 4:47
Rajdeep.NET is BACK2-Apr-09 4:47 
GeneralRe: Datagridview ComboboxColumn Error: System.ArgumentException: The value of DatagridviewComboboxCell is invalid Pin
Priya Prk2-Apr-09 4:53
Priya Prk2-Apr-09 4:53 
QuestionCSharp equivalent functions Pin
BINOVAR2-Apr-09 4:35
BINOVAR2-Apr-09 4:35 

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.