Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. public static string EncodeBase36(int i)
  2. {
  3. Contract.Requires<ArgumentException>(i>=0);
  4. //Base conversion
  5. string s="";
  6. while(i!=0)
  7. {
  8. int digit = i % 36;
  9. i/=36;
  10. if(digit<10)
  11. s=((char)('0'+digit)).ToString()+s;
  12. else
  13. s=((char)('a'+digit-10)).ToString()+s;
  14. }
  15. // Enforce minimum length
  16. while(s.Length<3)
  17. {
  18. s = "0" + s;
  19. }
  20. return s;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement