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; }


LinkBack URL
About LinkBacks






Reply With Quote