Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. static void DivideIndex(List<string> inputString, int index, int partitionsToDivide)
  2. {
  3. string positionName = inputString[index];
  4. int partitionSize = positionName.Length / partitionsToDivide;
  5. string[] positionNameArray = new string[partitionsToDivide];
  6.  
  7. inputString.RemoveAt(index);
  8. int counterTest = 0;
  9. for (int i = 0; i < partitionsToDivide; i++)
  10. {
  11. string test = string.Empty;
  12. if (i != partitionsToDivide -1)
  13. {
  14. test = positionName.Substring(counterTest, partitionSize);
  15.  
  16. }
  17. else
  18. {
  19. test = positionName.Substring(counterTest, partitionSize + positionName.Length % partitionsToDivide);
  20. }
  21. inputString.Insert(index +i,test);
  22.  
  23. counterTest += partitionSize;
  24. }
  25. //int posiitionNameArrayIndex = 0;
  26. //int counterCheck = 0;
  27.  
  28. //for (int i = 0; i < positionName.Length; i++)
  29. //{
  30. // positionNameArray[posiitionNameArrayIndex] += positionName[i].ToString();
  31. // counterCheck++;
  32. // if (counterCheck == partitionSize && posiitionNameArrayIndex !=partitionsToDivide -1)
  33. // {
  34. // posiitionNameArrayIndex++;
  35. // counterCheck = 0;
  36. // }
  37. //}
  38. //inputString.RemoveAt(index);
  39.  
  40. //for (int j = partitionsToDivide -1; j >= 0; j--)
  41. //{
  42. // inputString.Insert(index, positionNameArray[j]);
  43. //}
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement