Get Javascript Random Value


/ Published in: C#
Save to your folder(s)

drunkenprogrammer


Copy this code and paste it in your HTML
  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. }

URL: ideabubbling.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.