Posted By

zvasanth on 12/29/07


Tagged

get javascript random Value


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


Get Javascript Random Value


 / Published in: C#
 

URL: ideabubbling.com

drunkenprogrammer

  1. public static string GetJavascriptRandomValue()
  2. {
  3. Random ranDouble = new Random();
  4. string strd1 = ranDouble.NextDouble().ToString();
  5. int strd1len = strd1.Length;
  6. Random ranLong = new Random();
  7. string strd2 = ranLong.Next().ToString() + ranLong.Next().ToString();
  8. int intDefLength = 18;
  9. string strCutFromstrd2 = string.Empty;
  10. if (strd1len < intDefLength)
  11. {
  12. strCutFromstrd2 = strd2.Substring(0, intDefLength - strd1len);
  13. }
  14. string strRes = strd1 + strCutFromstrd2;
  15. return strRes;
  16. }

Report this snippet  

You need to login to post a comment.