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

C#

 
AnswerRe: A Couple of Questions Pin
Abhinav S30-Dec-09 16:29
Abhinav S30-Dec-09 16:29 
AnswerRe: A Couple of Questions Pin
petercrab30-Dec-09 18:28
petercrab30-Dec-09 18:28 
GeneralRe: A Couple of Questions Pin
Steven857930-Dec-09 19:34
Steven857930-Dec-09 19:34 
GeneralRe: A Couple of Questions Pin
ely_bob31-Dec-09 9:02
professionalely_bob31-Dec-09 9:02 
Questionsingle instance using C# and WinAPI Pin
Jassim Rahma30-Dec-09 10:47
Jassim Rahma30-Dec-09 10:47 
AnswerRe: single instance using C# and WinAPI Pin
Jimmanuel30-Dec-09 10:54
Jimmanuel30-Dec-09 10:54 
AnswerRe: single instance using C# and WinAPI Pin
DaveyM6931-Dec-09 1:43
professionalDaveyM6931-Dec-09 1:43 
QuestionC# test if number exists in array and if not put it in Pin
Wheels01230-Dec-09 8:28
Wheels01230-Dec-09 8:28 
Good afternoon.

I was wondering if there was a better was to check for duplicate numbers in an array and if it is not in the array, put it in.

This is what I have so far:

int[] numbers = new int[1000];  //Global
  
private bool RndDuplicate(int intRnd)
        {     
            int index = Array.BinarySearch(numbers, 0, numbers.Length, intRnd);

            if (index > 0)
            {
                return true;
            }
            else
            {
                //Load array
                for (int i = 0; i < numbers.Length; i++)
                {
                    if (numbers[i].ToString() == "")
                    {
                        numbers[i] = intRnd;
                        break;
                    }
                }
                return false;
            }
        }      


Thank you, WHEELS
AnswerRe: C# test if number exists in array and if not put it in PinPopular
harold aptroot30-Dec-09 8:47
harold aptroot30-Dec-09 8:47 
GeneralRe: C# test if number exists in array and if not put it in Pin
Wheels01230-Dec-09 9:10
Wheels01230-Dec-09 9:10 
GeneralRe: C# test if number exists in array and if not put it in Pin
harold aptroot30-Dec-09 9:12
harold aptroot30-Dec-09 9:12 
GeneralRe: C# test if number exists in array and if not put it in Pin
harold aptroot30-Dec-09 9:10
harold aptroot30-Dec-09 9:10 
GeneralRe: C# test if number exists in array and if not put it in Pin
Luc Pattyn30-Dec-09 9:32
sitebuilderLuc Pattyn30-Dec-09 9:32 
AnswerRe: C# test if number exists in array and if not put it in PinPopular
Luc Pattyn30-Dec-09 8:47
sitebuilderLuc Pattyn30-Dec-09 8:47 
GeneralRe: C# test if number exists in array and if not put it in Pin
Wheels01230-Dec-09 8:58
Wheels01230-Dec-09 8:58 
GeneralRe: C# test if number exists in array and if not put it in Pin
Luc Pattyn30-Dec-09 9:12
sitebuilderLuc Pattyn30-Dec-09 9:12 
GeneralRe: C# test if number exists in array and if not put it in Pin
PIEBALDconsult30-Dec-09 10:56
mvePIEBALDconsult30-Dec-09 10:56 
AnswerRe: C# test if number exists in array and if not put it in Pin
Islorvat30-Dec-09 8:47
Islorvat30-Dec-09 8:47 
GeneralRe: C# test if number exists in array and if not put it in Pin
Wheels01230-Dec-09 8:59
Wheels01230-Dec-09 8:59 
GeneralRe: C# test if number exists in array and if not put it in Pin
Alex Manolescu30-Dec-09 9:46
Alex Manolescu30-Dec-09 9:46 
GeneralRe: C# test if number exists in array and if not put it in Pin
#realJSOP30-Dec-09 9:48
mve#realJSOP30-Dec-09 9:48 
GeneralRe: C# test if number exists in array and if not put it in Pin
Alex Manolescu30-Dec-09 9:54
Alex Manolescu30-Dec-09 9:54 
GeneralRe: C# test if number exists in array and if not put it in Pin
#realJSOP30-Dec-09 23:45
mve#realJSOP30-Dec-09 23:45 
GeneralRe: C# test if number exists in array and if not put it in Pin
Alex Manolescu31-Dec-09 0:30
Alex Manolescu31-Dec-09 0:30 
AnswerRe: C# test if number exists in array and if not put it in Pin
Jimmanuel30-Dec-09 10:02
Jimmanuel30-Dec-09 10:02 

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.