|
Russell Jones wrote: i'd create an arraylist with all the numbers in order and an empty arraylist.
then get a random number minimum 0 and less than the length of the arraylist. move that item from the first list to the second and repeat until the first arraylist is empty.
We had this discussion before, Mr. Jones[^]
Cheers,
Vikram.
The hands that help are holier than the lips that pray.
|
|
|
|
|
ha brilliant,
I can't believe that with the number of posts you must read in a day you can remember a post from March, let alone take time to find it.
I notice that Christian's suggestion of a custom sort must have stuck in my brain.
Point taken but my answer still stands
|
|
|
|
|
This will pick ten unique numbers in the range 1 to 100, sorted from lowest to highest:
int range = 100, cnt = 10;
int[] num = new int[cnt];
Random rnd = new Random();
for (int current = 1; cnt > 0; current++) if (rnd.Next(range--) < cnt) num[num.Length - (cnt--)] = current;
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
If you use .NET 3.5 you can also use a HashSet :
do { set.Add(rand.Next(min, max)); } while (set.Count < 10);
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Is there a way to create a dll with classes that incorporate Windows Forms?
I was thinking of collecting some of the functionality for Windows Forms I re-use but Visual Studio won't let me use the System.Windows.Forms namespace in a DLL.
Why is that anyway?
I mean surely the namespace itself is inside a dll that visual studio uses?
Is there any way to create a DLL with the System.Windows.Forms namespace?
Thanks in advance
|
|
|
|
|
Just add a dll to the toolbox...
|
|
|
|
|
What do you mean?
The project itself is a dll.
And the problem is, VS won't let me use the System.Windows.Forms namespace.
|
|
|
|
|
In Solution Explorer|References folder, right click and choose Add Reference, then select System.Windows.Forms from the list... then you can use the namespace anywhere in your solution
Dave
|
|
|
|
|
I know, but that didn't work.
I found the error though, my VS is apparently messed up.
When I add references, it doesn't always work.
I found out because Microsoft Enterprise Library references were added in one project but adding the references in a different project didn't work and I had to manually look for the dlls and add them as file references.
I suppose it's the same problem in this case.
|
|
|
|
|
Hi All,
I want to read a DTD file and show it in a tree view.
Thanks in advance.
Regards,
Chanzeb Chaudhary
|
|
|
|
|
That's nice. Now where is your problem?
|
|
|
|
|
string file=@"c:\sample.dtd"
xmlDocument dtd=new xmlDocument();
dtd.Load(file);
Whether the above piece of code works or not???
I have tested it against XML documents(e.g. "sample.xml")
|
|
|
|
|
I have a problem in the following coding
protected void DataList1_ItemDataBound1(object sender, DataListItemEventArgs e)
{
DBCode dbo = new DBCode(); //class
DataTable dt = new DataTable();
dt = dbo.getDataTable("select IsSold, IsNew from product");
int a, b;
int c = int.Parse(dt.Rows.Count.ToString());
for (int i = 1; i <= c-1; i++)
{
a = int.Parse(dt.Rows[i]["Issold"].ToString());
b = int.Parse(dt.Rows[i]["IsNew"].ToString());
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (a == 1)
{
Label imgsold = e.Item.FindControl("lblsold") as Label; imgsold.Visible = true;
}
else
{
Label imgsold = e.Item.FindControl("lblsold") as Label; imgsold.Visible = false;
}
if (b == 1)
{
Label imgnew = e.Item.FindControl("lblnew") as Label; imgnew.Visible = true;
}
else
{
Label imgnew = e.Item.FindControl("lblnew") as Label; imgnew.Visible = false;
}
}
}
}
I want to enable and disable a label control with respect to the data coming from the database . this is actually a image gallery where i want make the image displayed with a tag new and sold . I have used datalist control and a two labels inside for displaying new and sold. but this code is not working so please help i am stuck in middle of the project
for further reference visit www.painternet.com/gallery.aspx
ram
|
|
|
|
|
Hey Ram,
clarify some things first.
what is ListItemType? is it a data list view?
also you can change int c = int.Parse(dt.Rows.Count.ToString()); to
int c = dt.Rows.Count cos the return type here is already int.
In the server, what datatypes are used for IsNew and IsSold?
What are the errors, if any?
He who goes for revenge must first dig two graves.
|
|
|
|
|
Hi
I want to use SQL View in my project. Is there any class in C# having functionality to produce SQL View.
Thanks
Atul
|
|
|
|
|
You use it just like a table, expect you can modify it.
|
|
|
|
|
Hello,
i'm developing at the moment a server-application, what can i do when my server has no performance anymore for this software? i could install it on a second server, thats right, but my problem is then to get variables, lists and other resources from the first server. how is something like that possible?
because big web-services for example google doesn't run on only one server too, so how can i make this that i can run one server-process per server but can access to the resources, lists and so on from the other servers?
|
|
|
|
|
1. Redesign your application/algorithm to run better.
2. Use remoting to communicate.
You will likely have to redesign most of the structure to support a distributed computing environment.
|
|
|
|
|
Well yes of course i could make my algorithm faster, but i have no idea which performance i need and so on, so i want to make it possible to use more server, now and not then when i see my server has no performance anymore
so how can i do this with the .net remoting, i've searched a little bit in the web but i can't find something really useful, has somebody a very simple example?
what does .net remoting? does it send easyly an object to another server?
|
|
|
|
|
Try google for distributed processing - its a very large and complex subject.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi,
I am running a .Net windows application on Vista platform. The code has some registry modification code. The code giving and access security exception if I am not expilictly running in administrator permission. Is there any way to run the application with the administrator permission by the code itself. Is that the CAS feature of the .Net framework?
please guide me.
|
|
|
|
|
|
Hello everyone,
As mentioned here,
http://msdn.microsoft.com/en-us/library/system.decimal(VS.80).aspx
"Conversions from Decimal to other types are narrowing conversions that round the Decimal value to the nearest integer value toward zero."
It conflicts my previous understanding that in all rounding in C#, we round to the nearest integer. Here is my test code. How strange it is, right?
using System;
class Test
{
static void Main()
{
Decimal b = 100.9M;
int a = (int)b;
Console.WriteLine(a);
return;
}
}
thanks in advance,
George
|
|
|
|
|
Well, it's doing what the docs say, so what's the problem ?
I guess the idea is that a Decimal is money, and if you have 100.9, you do not have 101.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Interesting answer, cool Christian!
regards,
George
|
|
|
|