|
public class MyClass : ICloneable
{
public object Clone()
{
return (object)this;
}
}
|
|
|
|
|
hI,
I have a web page in which i am generating all the controls dynamically .I have a place holder(also dynamically generated)in webform1 into which i am pushing all the All the generated controls .
Now i want ato inherit this page into webform2 .What i tried was
public class Webform2 : webform1
in webform class i have a ftion
public void look()
{
// Response.Write("look");
PlaceHolder pl = new PlaceHolder();
TextBox tb;
tb = new TextBox();
tb.Text = "adarsh";
tb.Visible = true;
tb.Width = Unit.Percentage(20);
tb.Height = Unit.Percentage(20);
pl.Controls.Add(tb);
this.form1.Controls.Add(pl);
}
}
in webform2 class i call page load event i call this ftion look .But it gives a runtime exception saying in line this.form1.Controls.Add(pl); object reference not set to an instance of an object.Why is this and pls suggest any solution for this.
-- modified at 1:54 Monday 3rd July, 2006
|
|
|
|
|
i had barcode but please help me to use it in my project
i dont how to use it which control would help me to use it and and how how to use what it read
|
|
|
|
|
omar el halwagy wrote: i had barcode but please help me to use it in my project
i dont how to use it which control would help me to use it and and how how to use what it read
You had it and now you don't? Don't quite understand your question. If you're looking for a barcode control, go here[^] and hope this can help you out.
|
|
|
|
|
not abl 2 understand ur question. anyway i assume that U have barcode scanner u want to read the barcode display it in some boxes. right?? for that there is no spl controls. place cursor in the textbox and scan the barcode using barcode scanner now the barcode will be displayed in textbox. if my assumption is correct the answer is correct.
|
|
|
|
|
first thanx for help
i had the bar code scaner and want to use what it read
(take what it read in any box (textbox))want to know which control to use
|
|
|
|
|
The simplest way to use a barcode scanner is as a keyboard replacement - that when a barcode is scanned, the scanner hardware or software simulate pressing the keys that correspond to the barcode data. Some just act as if they are a keyboard, some need some software (normally called a 'keyboard wedge' or 'scan wedge' or something like that) to do this. Consult the scanner's manual.
For advanced uses, there may be an API available to get input directly from the scanner, bypassing the keyboard. You might want to do this if you want to differentiate between keyed and scanned data.
To configure what sorts of barcodes the scanner will read, the scanner normally understands special programming barcodes. You can scan these to set the scanner up. You'll find these codes in the scanner's manual. Again, for advanced uses, there may well be an API for programming the scanner.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
I'm using a very fast loop and I'm using the Random object to get random numbers. The problem is that i'm suspecting that, as the loop is fast, numbers are not that random.
Is there a way to get to this? I've read something like locking the seed or something like that O_o
Thanx for any help.
|
|
|
|
|
|
It is outside.
Is there any way to randomize it more?
|
|
|
|
|
sergestusxx wrote: Is there any way to randomize it more?
What do you mean by randomizing it more? I've tested the random class and it seems to be quite random. You can specify a seed value in the class constructor.
Back in the old days with QuickBasic, one could use the statement RANDOMIZE TIMER and this would set the seed to whatever the PC's internal timer clock was at.
Try something like this:
Random randNum = new Random(DateTime.Now.Millisecond);
Everytime you have a new instance of randNum, it should generate a different set of random numbers (unless the code happens to be initiating at the same exact millisecond 1/1000 chance ).
Hope this helps some,
PJC
|
|
|
|
|
Problem is, it's not hard at all to have a loop hit that statement more than once per millisecond. And I've also seen some results that make me want a more random solution myself.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
BoneSoft wrote: it's not hard at all to have a loop hit that statement more than once per millisecond
It should be outside the loop. The original poster said outside the loop.
Another solution I thought of for the original poster was to create your own random number generator. The old Ada compiler that I have, the company had a sample random number generator program that was rather sophisticated.
|
|
|
|
|
|
The Random object produces a random number using the previous number as seed. It doesn't matter if you get the numbers an hour apart or a nanosecond apart, you will still get the same sequence of numbers.
Assuming of course that you use the same Random object, and doesn't create a new one for each random number.
---
b { font-weight: normal; }
|
|
|
|
|
If you doubt the "randomness" of System.Random (which is independent of the frequency you call Next() with), you should take a look at System.Security.Cryptography.RandomNumberGenerator and derived classes.
They tend to generate a better distribution of random numbers, from what I've read.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
|
|
Hi guys!
A quick question from a c# newbie. Please take a look at the following two examples:
EXAMPLE 1:
using System;
using System.Collections;
class Tester
{
public static void Main()
{
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
int[] z = { 4, 5, 6 };
x["2"] = z;
Console.WriteLine(((int[])x["1"])[1]);
Console.WriteLine(((int[])x["2"])[1]);
System.Threading.Thread.Sleep(25000);
}
}
EXAMPLE 2:
using System;
using System.Collections;
class Tester
{
public static void Main()
{
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
y[0] = 4; y[1] = 5; y[2] = 6;
x["2"] = y;
Console.WriteLine(((int[])x["1"])[1]);
Console.WriteLine(((int[])x["2"])[1]);
System.Threading.Thread.Sleep(25000);
}
}
Example 1 produces the desired output 2 and 5 whereas Example 2 returns 5 and 5.
The only difference being that in Example 1 two variables were used (y and z) to write data to the hashtable whereas Example 2 uses only one variable (y). IMO both cases should produce the very same output, but they obviously don't. Could anyone explain to me why not? I don't understand the logic behind this. Do I always have to use different variables when writing to a hashtable? That would be very inconvinient, especially if the table were to consist of hundreds or even thousands of items!
Any help is greatly appreciated!
Thans for your efforts!!!
Mazze
|
|
|
|
|
What you are storing in the hash table is not the array itsef, but a reference to the array. In the second example you are storing two references to the same array. That means that any change you make to the array will be visible from both references.
You don't need to use different variables, you only have to create separate objects.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa,
Thanks for your quick reply!
I wasn't aware of the hashtable only storing a reference of the array rather than the array values. That explanation was of great help to me.
I'm afraid, but I'm still stuck on how to go about creating separate objects. The main purpose of this particular hashtable is to save array values (the actual values, not a reference!) as 'y' changes. Could you give me an example as to how to resolve this without creating a new array for each item?
Thank you!
Mazze
|
|
|
|
|
But you have to create a new array for each item. A hash table is not capable of storing array values directly, you have to put the values in an array and store the reference to the array in the hash table.
I believe that you are not aware of where exactly you are creating the array.
The code:
int[] y = { 1, 2, 3 };
is the short form of:
int[] y = new int[] { 1, 2, 3 };
which is the same as:
int[] y;<br />
y = new int[] { 1, 2, 3 };
So, in that statement you are declaring a variable that can hold a reference to an array, then you create the array and store the reference in the variable.
If you want to make a copy of an array, you can use the Clone method. As long as the data in the array is a value type, it will create a fully independent copy of the array.
The Clone method returns an object reference, so you have to cast it to the correct type:
int[] y = { 1, 2, 3 };<br />
int[] z = (int[])y.Clone();
---
b { font-weight: normal; }
|
|
|
|
|
Hello
Your mistake in Example2 was changing the values of the same array, which eventually will change in the HashTable too.
Proposed solution:
Dynamically allocate another Array using the same name:
eg.
Hashtable x = new Hashtable();
int[] y = { 1, 2, 3 };
x["1"] = y;
y = new int[] { 4, 5, 6 };
x["2"] = y;
MessageBox.Show(((int[])x["1"])[1].ToString());
MessageBox.Show(((int[])x["2"])[1].ToString());
PS.
Beware of the Garbage Collector
Regards
|
|
|
|
|
Guffa,
Nader,
Thanks for helping me resolve this issue. I now have a grasp of what's meant by creating two separate objects. Everythings works fine! Great!!!
As mentioned earlier, I'm a newbie so sorry for asking questions that are crystal clear to advanced programmers.
Once again, thank you guys!
Have a great day!
Mazze
|
|
|
|
|
how to Windows Service.plx help me by step by step solution;
|
|
|
|