Cassie Mod

Cassie Mod

  • NA
  • 488
  • 70.4k

How to declare if yopu don't know the element ammount?

Feb 28 2017 5:59 AM
HI,
 
Ive got the following question?
how can i declare an array if you don't know how manny elements the array will finally contain ? 
 
here is my example.  I sed the wcfUser array could contain 1000 elements ( simply because i need to do a test to add 1000 users) but the wcfUser array could at the end just contain for example 15 elements ( you don't know it yet).
 
here is my code;
  1. WcfUser[] usersInGroup = new WcfUser[1000];  
  2.   
  3. // Get users GroupUsers request  
  4. var request = new GetGroupUsersRequest  
  5. {  
  6. requestId = _requestId,  
  7. serviceProviderId = "DO_onepro",  
  8. jSessionId = _jsessionId,  
  9. sessionId = _sessionId,  
  10. domain = "1pro.deanone.nl",  
  11. groupId = "1PRO_DEMOIVO",  
  12. requestUsername = "mhussein"  
  13. };  
  14.   
  15. // GroupUsers response  
  16. using (var client = new TechnicServiceClient())  
  17. {  
  18. var response = client.GetGroupUsers(request);  
  19. var errorCode = response.errorCode;  
  20. var errorMessage = response.errorMessage;  
  21. usersInGroup = response.users;  
  22. }  

Answers (3)