+ Reply to Thread
Results 1 to 3 of 3

Thread: c# new array

  1. #1
    Acceptu is offline Just a "Little" Kid Acceptu is on a distinguished road
    Join Date
    Aug 2005
    Posts
    103
    Rep Power
    8

    Smile c# new array

    Morning All

    As you can see iv not been around for a while but hope every one is well.

    In this little bit of C# im having to count the size of the array i need then create a new array, is there a better way i can do this?


    Code:
            public string[] getusernames()
            {
                int compcount = 0;
                string[] getusername = new string[100];
                compcount = 0;
                for (int count = 0; count < computer.Length; count++)
                {
                    if (!checkifinlist(getusername, computer[count].getusername()))
                    {
                        getusername[compcount] = computer[count].getusername();
                        compcount++;
                    }
                }
                string[]usernames = new string[compcount];
                compcount = 0;
                for (int count = 0; count < computer.Length; count++)
                        {
                        if(!checkifinlist(usernames, computer[count].getusername())) {
                            usernames[compcount]=computer[count].getusername();
                        compcount++;
                        }
                    }
                return usernames;
            }

  2. #2
    NewEra's Avatar
    NewEra is offline A Toddler - Don't be Fooled! NewEra is on a distinguished road
    Join Date
    Sep 2005
    Posts
    104
    Rep Power
    8

    Re: c# new array

    why don't you use C++ its better with array

  3. #3
    Acceptu is offline Just a &amp;quot;Little&amp;quot; Kid Acceptu is on a distinguished road
    Join Date
    Aug 2005
    Posts
    103
    Rep Power
    8

    Re: c# new array

    Thought i replied earlyer

    Im making a remote gui admin tools

    Ive made a bit of progress
    Code:
                int depcount = 0;
                string[] checkdepartments = new string[20];
    
                for (int count = 0; count < computer.Length; count++)
                {
                    if (!checkifinlist(checkdepartments, computer[count].getdepartment()))
                    {
                        checkdepartments[depcount] = computer[count].getdepartment();
                        depcount++;
                    }
                }
                string[] getdepartments = new string[depcount];
    
                for (int count = 0; count < depcount; count++)
                {
                    getdepartments[count] = checkdepartments[depcount];
                }
                return getdepartments;

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Need array tut
    By the average joe in forum PHP Scripting
    Replies: 2
    Last Post: 08-02-2010, 11:39 PM
  2. #define and array
    By Dimkin in forum C and C++ Programming
    Replies: 1
    Last Post: 10-26-2008, 11:49 AM
  3. Help with array feeding an array
    By callumjones in forum PHP Scripting
    Replies: 2
    Last Post: 05-23-2007, 01:42 AM
  4. array 2 image
    By StarIsFar in forum Java Programming
    Replies: 9
    Last Post: 04-26-2007, 12:22 AM
  5. Array process
    By StarIsFar in forum Java Programming
    Replies: 7
    Last Post: 03-04-2007, 06:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts