We Recommend

Accelerated C# 2008 Accelerated C# 2008
This book is both a rapid tutorial and a permanent reference. You’ll quickly master C# syntax while learning how the CLR simplifies many programming tasks. You’ll also learn best practices that ensure your code will be efficient, reusable, and robust. Why spend months or years discovering the best ways to design and code C# when this book will show you how to do things the right way, right from the start?


Posted By

zvasanth on 12/29/07


Tagged

get javascript random Value


Versions (?)


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.