TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sivasankaran Gurusamy
NA
7
2.9k
Lambda Expression
Mar 2 2015 9:28 AM
Hi Guys,
Please help me to build Lambda expression for below C# for loop , Because the below for loop getting high CPU..
for (int i = 1; i <= dQuantity; )
{
double dlRnd = rnFirst.NextDouble();//with seed
if (dlRnd < 0.0001)
dlRnd += 0.012;
//string strRndFirstDgt = dlRnd.ToString().Substring(2, iFirstPinLng);
long strRndFirstDgt = ExtractDigits(dlRnd, 2, iFirstPinLng);
//----Second Rnd ------ 0.6 91979 52919 26617
double dlSecondRnd = rnSecond.NextDouble(); //Without Seed. 58535 03461 123
if (dlSecondRnd < 0.0001)
dlSecondRnd += 0.012;
long strRndSecondLastsixDgt = ExtractDigits(dlSecondRnd, dlSecondRnd.ToString().Length - iSecondPinLng, iSecondPinLng);
//string strRndSecondLastsixDgt1 = dlSecondRnd.ToString().Substring(dlSecondRnd.ToString().Length - iSecondPinLng, iSecondPinLng);
long conCan = Convert.ToInt64(strRndFirstDgt.ToString() + Convert.ToString(strRndSecondLastsixDgt));
long temp;
temp = Convert.ToInt64(conCan) + DateTime.Now.Ticks; //addition to pin+ datetime Ticks
int intRndThird = rnThird.Next(1, 10);//To avoid the prefix value 0's;
// string conCanRnd = intRndThird.ToString() + Convert.ToString(ExtractDigits(temp,temp.ToString().Length - pinLength, pinLength - 1));
long conCanRnd = Convert.ToInt64(stInt.ToString() + intRndThird.ToString() + (temp.ToString().Substring(temp.ToString().Length - pinLength, pinLength - 1)));
// long sessionconcatpins = Convert.ToInt64(stInt.ToString() + conCanRnd); // Append Concurent User Hit Count in to PINS
if (lstpins.Add(conCanRnd))
i++;
if (i % 100 == 0)
{
lngDateTicker = DateTime.Now.Ticks;
strSeedLastNineDgt = lngDateTicker.ToString().Substring(7, 9);
rnFirst = new Random(Convert.ToInt32(strSeedLastNineDgt));
}
}
Reply
Answers (
4
)
Error
Why var is used before linq query