如何在购物车的网上购物中生成随机数。 [英] how to generate random number in online shopping for shopping cart.
本文介绍了如何在购物车的网上购物中生成随机数。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的项目中,我有一个购物车页面..在这个我用继续购物作为按钮继续购物..但我有一个问题..点击这个新的随机数生成所以在购物车页面只显示一个产品..
in my project i have a shopping cart page.. In this i used continue shopping as a button to continue the shopping.. but i have a one problem.. after click on this new random number is generated so in the cart page only one product is displayed..
推荐答案
随机类在c#
随机rd = new Random();
int no = rd.next()//得到随机非重复的没有
...你的问题不明确,我想这会有所帮助你要解决你的问题
Random class is there in c#
Random rd=new Random();
int no=rd.next() //get random non repetitive no's
...your question is not clear,I think this will help you to solve your problem
private readonly Random _rng = new Random();
private const string _chars = ABCDEFGHIJKLMNOPQRSTUVWXYZ;
< br $>
公共字符串RandomString(int size)
{
char [] buffer = new char [size];
for(int i = 0; i& amp; lt; size; i ++)
{
buffer [i] = _chars [_rng.Next(_chars.Length)]; < br $>
}
返回新字符串(缓冲区);
}
MARK AS如果你得到结果答案
private readonly Random _rng = new Random();
private const string _chars = ABCDEFGHIJKLMNOPQRSTUVWXYZ ;
public string RandomString(int size)
{
char[] buffer = new char[size];
for (int i = 0; i &lt; size; i++)
{
buffer[i] = _chars[_rng.Next(_chars.Length)];
}
return new string(buffer);
}
MARK AS Answer IF YOU GET RESULT
c#has一个随机
函数,可用于生成随机数。这可用于生成随机项目列表。
c# has a random
function that you could use to generate random numbers. This can be used to generate random item lists.
这篇关于如何在购物车的网上购物中生成随机数。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文