|
Hi,
I dont understand all of it;
not using the PRE tags makes this harder to read than is necessary.
But with what I can figure out, seems to me there are many mistakes:
1.
g.Dispose(): as Guffa already said, dont dispose of things you did not create.
2.
I am puzzled by your NO_Click()
cant figure out what control would invoke this, nor what sense it makes
just changing a border style.
Showing the constructor might have been useful...
3.
on button1_Click you create a new NO
so every time it happens another NO is added, 50 dots to the right of the
previous one? is that really the intention?
if you only need either none or one NO object, I suggest you create it beforehand
(probably using Designer) and keep it invisible until you want to see it.
4.
un_Click(): why is it you set the keydown event only after having clicked "un" ?
I guess you could have done that right away, it would only fire when is has
focus anyway. You are making things more complex than necessary.
5.
it might help us if you better explain (and show code about):
- what the intial state should be and is;
- what the functionality of the NO class is;
- and exactly what goes wrong, after exactly which actions the user takes.
But maybe you first want to clean-up your code based on the above input,
then replublish it inside PRE tags (have a look at other messages, then
use the little "pre" button under the window where you enter your messages...
|
|
|
|
|
i want to know how to connect the application to the db and create the user logins in the db via the application.do you have any idea....
|
|
|
|
|
prasadbuddhika wrote: i want to know how to connect the application to the db
SqlConnection conn = new SqlConnection(theConnectionString);
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = anySqlCommand;
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();
theConnectionString is defines where and how to connect to your database. For the functions you wish to carry out you will need a connection with sysadmin privileges. See http://www.connectionstrings.com[^] for details on what connection strings look like.
anySqlCommand is a string that can be pretty much any command that SQL Server understands. You can even dump entire scripts in there. The only thing it can't deal with is the GO, because that isn't SQL, it is a delimiter that Query Analyzer or the SQL Server Management Studio uses to separate batches of SQL statements.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
Hi,
I have a form Form1 I want to refresh the form after every 10 seconds how to implement this.
|
|
|
|
|
you can just use a timer from System.Threading namespace.
|
|
|
|
|
Hi Ekynox,
Thanks for reply....
Actually I have a DataGridView in Form1 in my Windows Application and now i want to refresh the datagridview every some time....
Can u help me with a sample code....
|
|
|
|
|
do you know how to fill a datagridview ? then put the code that fills a datagridview inside the timer object. cant be that hard.
|
|
|
|
|
|
hi all,
i m new in C#, can anyone hlep me to return values from an ArrayList??
coz in arraylist u can add multityes of values, so how can i return these multitype values from a single return function??
please help me.
thanks
Baljit Singh Grewal
|
|
|
|
|
You return the arraylist itself.
If you're using C# 2.0, you should never use ArrayList, use the generic List class instead. And if you're using 1.0 or 1.1, stop if you can. The C# 2.0 Express Edition is free.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Obviously you are new to posting in forums also.
You should choose a subject line that describes the area of your question. A general greeting is not useful at all as a subject.
Also, your question is pretty vague, so it's hard to offer any suggestions.
The return value from a function has to be a single entity, so if you have multiple values, you have to put them into some kind of data type that supports multiple values, like an ArrayList.
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Please don't post the same question twice.
How does a string have a max or min value, by what rules ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You could create a user defined function in SQL Server 2005 to give Min and Max of a String, which you would have to define the rules of what is the Max of a string and Min of a string.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
hi all
i wount to select max(string)from database
the database is sql server2005
who i can do tht without do any thing in code(c#)
thanks for any body help me
Thaer
|
|
|
|
|
Don't post the same question twice, please
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I've used C# for a few years now and have not needed to use its pointers feature. However, I'm in the process of optimizing some code, and I'm looking at pointers as one way to improve performance. The code I'm working with makes extensive use of arrays. Lots and lots of tight loops in which the results are assigned to elements in a array.
I wrote the following console app to compare pointer performance to array performance:
using System;
using System.Diagnostics;
namespace PointerTest
{
class Program
{
private const int Size = 10000000;
static void Main(string[] args)
{
Stopwatch watch = new Stopwatch();
float[] data = new float[Size];
unsafe
{
fixed(float* p = data)
{
watch.Start();
for(int i = 0; i < Size; i++)
{
p[i] = 1.0f;
}
watch.Stop();
Console.WriteLine("Pointer: " + watch.Elapsed.ToString());
}
}
watch.Reset();
watch.Start();
for(int i = 0; i < Size; i++)
{
data[i] = 1.0f;
}
watch.Stop();
Console.WriteLine("Array: " + watch.Elapsed.ToString());
Console.Read();
}
}
}
The program assigns 10 million items to a pointer pointing to an array and then does the same thing with the array directly. Here are the results:
Pointer: 00:00:00.1147978
Array: 00:00:00.0993352
I ran the program several times, and while the times varied, though not by a great amount, the result was the same: the pointer method is slower.
However, when I used an array size below about 20,000, the pointer method beat out the array method by a small amount.
Any thoughts or insights?
|
|
|
|
|
That matches what I have found as well, as I mentioned in this article[^]. I don't know the reason for it, but I've always found it to be so. Perhaps it could have to do with some extra checks that might done for pointers that are omitted with arrays because the JIT can make assumptions about arrays that it can't about pointers. It would be interesting to find out for sure what the cause is - but atm I unfortunately don't have the time to go poking around in the generated machine code.
--Justin,
Microsoft MVP, C#
|
|
|
|
|
Leslie Sanford wrote: Any thoughts or insights?
I like open questions... they indicate wisdom: either awareness of ignorance,
or a truely open mind!
In my experience measuring performance by looking at elapsed time is very good
if some precautions have been taken:
1.
the time must be long enough to average out some statistical disturbances, typically
things the system may do in the background; that's disk accesses, Ethernet
packets, anti-virus, whatever. I would suggest to increase the job tenfold.
2.
Be careful with the special situation for the first experiment: if your tests
share something (such as an array), it will not have been allocated in physical
memory, it will not yet have been (partially) loaded in level3 or L2 cache, etc.
Quite often, when comparing two alternatives, the second wins, not because
it is faster, but just because it gets the better starting conditions.
So the minimum one should do is swap both to see how much of a difference that
gives.
My approach to cover both issues typically is to perform all N different tests
one after another, but then loop over it for say 100 times.
Then either ignore the first iteration entirely, and/or do some statistical
analysis on those N result arrays.
But even then, for N>2 the order of the tests may also be significant, so it
might be better to sequence them at random.
Hope this helps.
|
|
|
|
|
Luc Pattyn wrote: I like open questions... they indicate wisdom: either awareness of ignorance,
or a truely open mind!
Thank you!
Luc Pattyn wrote: Quite often, when comparing two alternatives, the second wins, not because
it is faster, but just because it gets the better starting conditions.
So the minimum one should do is swap both to see how much of a difference that
gives.
You are right! I changed the order of the test and got nearly opposite results. The pointer method beat out the array method repeatedly.
Luc Pattyn wrote: My approach to cover both issues typically is to perform all N different tests
one after another, but then loop over it for say 100 times.
Then either ignore the first iteration entirely, and/or do some statistical
analysis on those N result arrays.
But even then, for N>2 the order of the tests may also be significant, so it
might be better to sequence them at random.
I rewrote the test using a smaller array. Then I ran the tests in a loop 10000 times. The pointer method beat out the array method by a small amount. I changed the order of the tests within the loop and got the same results. I ran the app several times and got consistent results.
It would seem that the pointer method may be faster based on my tests. I'll have to decide if the possible gain in speed is enough to justify changing my code. And perhaps improve my tests by doing a more thorough analysis of the results.
Luc Pattyn wrote: Hope this helps.
Absolutely! It's been an eye opener. Thank you.
|
|
|
|
|
Of course you are getting the same result. You are using a pointer to an array, which will produce the exact same code as using a reference to an array.
Try using the pointer directly instead:
for(int i = 0; i < Size; i++) {
p++ = 1.0f;
}
That should be a bit faster, as it doesn't produce any code to check the boundary of the array.
You should include the fixed structure inside the timing to make a fair comparison, as that is needed for the pointer operation. You should also test different sizes, to see how the code scales.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: p++ = 1.0f;
Unfortunately, that doesn't compile. I have to do this:
fixed(float* pSource = data)
{
float* p = pSource;
for(int i = 0; i < Size; i++)
{
*p = 1.0f;
p++;
}
}
Guffa wrote: That should be a bit faster, as it doesn't produce any code to check the boundary of the array.
My tests show that the above is slower than using the subscript operator on the pointer; the array method beats it out. I assume it's because incrementing the pointer is taking additional time.
|
|
|
|
|
I think you're getting messed up by memory management. If I just reverse the order of the tests I get opposite results. Try setting the data size to something around 1000 and then put an additional loop from 1...1000000 around the each of the for( int... Size) loops.
The loops are still pretty much the same. One adds i * sizeof( float ) each time around, the other increments by sizeof( float ).
The optimizer seems pretty stupid however. Changing
*p = 1.0f;
p++;
to
*p++ = 1.0f
nearly halves the result. Perhaps there is some switch to improve that sort of thing.
-- modified at 13:05 Saturday 28th July, 2007
looked at your post again and now see you're asking about the memory size impact so I guess I'm just restating the obvious.
|
|
|
|
|
Robert Surtees wrote: If I just reverse the order of the tests I get opposite results.
That was my experience as well.
Robert Surtees wrote: The optimizer seems pretty stupid however. Changing
*p = 1.0f;
p++;
to
*p++ = 1.0f
nearly halves the result. Perhaps there is some switch to improve that sort of thing.
Wow. I changed to *p++ = 1.0f and noticed an appreciable difference between the pointer method and the array method.
I have to say though that...
*p++ = 1.0f;
...makes the old C programmer in me cringe. But if it's that much faster...
|
|
|
|
|
Robert Surtees wrote: The optimizer seems pretty stupid however. Changing
*p = 1.0f;
p++;
to
*p++ = 1.0f
nearly halves the result. Perhaps there is some switch to improve that sort of thing.
Are you compiling in release mode, and not debug mode?
In that case it's a bit surprising.
---
single minded; short sighted; long gone;
|
|
|
|