0
Answer

A Little Help with a Small C-Sharp Script

Calvin Ellils

Calvin Ellils

16y
4.7k
1
Hi there,

I am currently working a small script as follows:-

for (Int32 i = 0; i < headerimgs.Rows.Count; i++)
        {
            if (i >= 63)
                break;
           
            string usrid = headerimgs.Rows[i][UsersPhotoCollection.UserIDColumnName].ToString();
            UsersRow usr = db.UsersCollection.GetByPrimaryKey(int.Parse(usrid));
           
            if (usr != null)
            {
                Response.Write("<site thumbID=" + '"' + EmailUtil.ApplicationFullPath + "/sys/UploadImages/" + usr.UserID + "/M/" + headerimgs.Rows[i][UsersPhotoCollection.UsersPhotoIDColumnName ].ToString() + ".jpg" + '"' + " url=\"" + EmailUtil.ApplicationFullPath + "/UserProfile.aspx?UserID=" + usrid + "\">");
                Response.Write("<title><![CDATA[" + usr.Nickname.ToString() + "]]></title>");
                Response.Write("</site>");
            }
        }

As you can see, the script currently generates a list of thumbnails and renders them sequentially by their ID number.

Can some one help me to modify it so that it achieves the following?

step 1: retrieve total number of rows
step 2: use the random() function to generate a random integer between a min and max integer, where min = 0 and max = total number of rows
step 3: store it in an array so that we can check that the random number is not already stored in the array
step 4: break out of the array creation loop once we have stored 60 data in the array.  I use "60" because that is the maximum number of thumbnails I want to generate.
step 5: use the i counter loop to use each random_i --> which is an integer retrieved from the aray

Appreciate anyone who can help me to include this small script into the above script.

Cheers,
Ellils