![]() |
| ||
| Comparing C# Int Arrays Hello all...my first official post (after the introduction) I'm relatively new in the area of C# (some PHP experience) and I'm hoping someone can help me. I have 2 arrays of variable lengths, with int data in them. Something like this: FreeNumbers = 1,2,3,4,5 UsedNumbers = 1,2 I want to take the first FreeNumber (1) and search through the used number array. If it exists there I want to move on to the next FreeNumber (2) and do the same. Once I find a FreeNumber (3) that is NOT in the UsedNumber array, I want to assign it to another var (TheNextFreeNumber). Can someone help me with this? I was thinking this should be done through For's, ForEach or Try/Catch but I'm just not quite getting there. Maybe there is an even simpler C# function? Thanks for any help. -Chris |
| ||
| Re: Comparing C# Int Arrays Can you use generics? They are a little easier to deal with than arrays: private void simpleButton2_Click(object sender, EventArgs e) |
| ||
| Re: Comparing C# Int Arrays I haven't used generics before. The arrays are already built and filled. Is there an easy way to move the aray data to the generics? There are about 300 elements per array. -Chris |
| ||
| Re: Comparing C# Int Arrays Yes: private void simpleButton2_Click(object sender, EventArgs e) |
| ||
| Re: Comparing C# Int Arrays That Got It! Thank you so much! Plus I learned about Generics for the first time. Will study up more on that. Here's the code I used in the end for those interested: List<int> free = new List<int>(); Now one more question...why didn't I join Daniweb sooner? :-) Thanks again |
| All times are GMT -4. The time now is 10:31 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC