|
Very smart solution
Thanks so much Robert
I'm fixing now
eric
|
|
|
|
|
Does any statistical wizard know exactly how much you'd need to randomly swap items like this before you had something that you could say wasn't biased by the fact that the items started in order?
I'm just curious.
BTW, what's the last for loop for?
|
|
|
|
|
I think it should be pretty simple for a statician (does this word exist?). Just calculate how likely it is that one index in the array isn't hit and multiply this with the length of the array.
Wjousts wrote: BTW, what's the last for loop for?
It was for myself trying to determine if one million switches would be enough. My tests mostly said that 0-2 elements were at its original position. Whether this was because they weren't hit by the algorithm or if they were just reswitched I don't know .
|
|
|
|
|
Robert Rohde wrote: It was for myself trying to determine if one million switches would be enough. My tests mostly said that 0-2 elements were at its original position. Whether this was because they weren't hit by the algorithm or if they were just reswitched I don't know .
That's what I thought you might be doing, but I think the logic to that might be flawed. You'd expect at least a few elements to be in the correct place just by chance. If five items just happen to end up in the correct place it doesn't mean the sequence isn't random. Even a random sequence could (in theory) end up being in exactly the right order.
|
|
|
|
|
You are absolutely rihgt. I just added it for me to check whether it is 'somehow random'. If the result would have been something like 1000 (I think the chance of having such a large number of items at their exact location should be near to zero) than I would not have posted the code .
|
|
|
|
|
That's pretty cool, but surely has the danger that numbers won't ever get hit and moved elsewhere, so you end up with a pretty random list with a few numbers exactly where they started.
Instead of swapping randomly, why don't you go through the array sequentially, and swap each number with a random one?
Regards,
Rob Philpott.
|
|
|
|
|
I've done something very similar several times (not as much as 100,000 though). The way I did it was this:
int[] myArray = new int[100000];
Random rnd = new Random();
ArrayList number = new ArrayList(100000);
for (int i=0; i<100000; i++)
{
number.Add(i);
}
for (int i=0; i<100000; i++)
{
int temp = rnd.Next(numbers.Count);
myArray[i] = numbers[temp];
numbers.RemoveAt(temp);
}
I populate an ArrayList with all the numbers and then randomly pull them out of the list and put them in my array. I don't know how efficient it'd be for 100,000 items though.
|
|
|
|
|
Hiiii,
I want to change the color of scroll bars...like u can see in Windows xp forms having a blue color scroll bar.
thanx
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
Hiii,
I m Working on an c# Desktop Application i need to change the color of scroll
bars...
Anuj Kamthan
Software Developer
Solversa Technologies,
Pune - 411007, India.
http://www.solversa.com
|
|
|
|
|
The WinForms platform does not provide a way to modify the appearance of a scrollbar. There is probably some way to accomplish that via P/Invoke. If that does not tickle your fancy, you can buy third-party controls (like the Infragistics NetAdvantage) and use their customizable scrollbars.
Josh
|
|
|
|
|
I have a class property that I want to be localisable. The MSDN gives an example as:
<br />
[<br />
Description ( "The name of this section" ),<br />
Category ( "Section" ),<br />
DisplayName ( "Section name" ),<br />
Localizable ( true )<br />
]<br />
public int MyProperty {<br />
get {<br />
return 0;<br />
}<br />
set {<br />
}<br />
}<br />
The help files say
When code is generated for a component, members that are marked with the
LocalizableAttribute set to true have their property values saved in resource
files. You can localize these resource files without modifying the code.
So I would expect all the attributes to appear in the .resx file, but they don't. Is this a bug, or am I doing something wrong?
|
|
|
|
|
I think you must also set Localizable of the Form the control is placed on also to true.
|
|
|
|
|
The class isn't on a form.
It's just a holder for information that can be used by PropertyGrid.
|
|
|
|
|
I wont my app workon mobile phone who support java.
But my app is writen in c# how can i convert it!
Thanks!!
nemanja
|
|
|
|
|
I believe you'll need to convert your C# code to Java.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Yes do you have it .Or does it really exist.
nemanja
|
|
|
|
|
No, you'll need to convert it manually. See this[^] link for more info.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
|
I wont my app work on moile phone .I create my app in c# .I dont know java but i was thinking i can get convertor but i can't find the convertor.
nemanja
|
|
|
|
|
well... with SharpZibLib you can create jar files ... it is like creating zip files but in stead of .zip it's .jar ...
|
|
|
|
|
Does convertor exists.
nemanja
|
|
|
|
|
JaCIL (pronounced "jackal") is a graduate capstone project to create a
byte-code compiler to translate CLI binaries to binaries suitable for
consumption by the JVM.
The project is on SourceForge, sorry no link, google.
|
|
|
|
|
Hello-
I found some code on the Internet for some dynamic breadcrumbs. The instructions say to include this code in the code-behind of the .aspx page:
***code***
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Sabre_Solutions.Loads.Topographic_Effects
{
///
/// Summary description for BreadCrumbTest.
///
public class BreadCrumbTest : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
protected System.Web.UI.WebControls.Literal lblPageTitle;
protected NameSpace.headerBreadCrumb header;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string PageTitle = "Test the Title";
lblPageTitle.Text = PageTitle;
header.HeaderText = PageTitle;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
***end code**
If you noticed, I bolded two lines of code. It looks like I am supposed to declare another class, but I'm not really sure what to put in the code. I assume I am to declare a header class. I researched and my attempts have not been successful.
Does anyone know what I am supposed to do to make these lines work? (The orignal article mentions nothing about these lines.)
|
|
|
|
|
It looks like OR you need to reference to an external assembly OR you have to create a class with that name and put some code (which is or which they forgot to mention on that website)...
|
|
|
|
|
How can I customize the RichTextBox so I can add line number, etc. nice things on the left side, just like what IDEs have?
|
|
|
|