|
Are you sure you're typing an upper-case X and not a lower-case x ? The latter is a private field and thus only accessible from the Point struct itself. Assigning the former (upper-case X ) is fine.
Also keep in mind that the Point struct (like all structs) is a value type. If you think you have a reference to it somewhere else and you didn't pass it using the ref keyword, then you're mistaken. If you pass Point as a param you pass a copy, not a reference. If you're expecting Offset to change that, it won't. Otherwise, it does modify the instance of the Point on which it was called.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
First of all, there is no "global" anything in .NET. If doesn't matter if these ArrayList s are instance or static members, the problem is that the Point struct is a value type and a statement such as
((Point)myArrList[i]).X = 13; is actually compiled to something similar to this
Point p = (Point)myArrList[i];
p.X = 13; Either way, therein lies the problem. Since the Point struct is a value type, you're actually making a copy of it (in p in this example), not assigning a reference to it. This is how value types work. It doesn't matter if you pass them as parameters or store them in a list. When you get them from the list you are getting a copy so the value type in the list will not be changed.
See the article, Value vs Reference Types in C#[^] (actually, all of .NET) for a comprehensive discussion of the topic.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
I just read the article, it was really informative...
But now there is a very big question in my mind:
Where should I store my Point structs so that be able to change their X and Y properties later, without requiring to reNEW them?
Don't forget, that's Persian Gulf not Arabian gulf!
|
|
|
|
|
You don't have to re-instantiate them, only re-add them to the ArrayList (or collection, or class member, etc.):
Point p = myArrList[i];
p.X = 13;
myArrList[i] = p;
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
somebodys can help me, how to use AxMediaPlayer to play any mp3 file on Internet.
thanks
Nho'c Ti`
|
|
|
|
|
Set the URL to a URL like http://host.domain.tld/dir/file.mp3. Download the Windows Media Player SDK[^] for nearly completely API documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi, I need to use a form control but without the round-edged windows title bar. Does anyone know how to get rid of the title bar. Anyway, I'm using C# in this Windows application. Thanks.
|
|
|
|
|
Set the ControlBox property to False and the Text property to blank.
|
|
|
|
|
You can also set Form.FormBorderStyle to FormBorderStyle.None .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
...which makes it really cool for use as a "splash" window, among other fun things you can do with a borderless form...
|
|
|
|
|
Hi,
I have functionality already implemented in double click event of ListView. Now I want to add a button that would do the same, but instead of writing everything for that button click event, I just want to fire the ListView Double Click event !
How can I achieve this ?
Thanks,
Paul
|
|
|
|
|
My suggestion is that you write another method and call that method from the Click and from the DoubleClick. Something like this:
private void listView1_DoubleClick(object sender, System.EventArgs e) {
someCommonLogic();
}
private void someCommonLogic() {
MessageBox.Show("Hello World!");
}
private void btnSharesMethod_Click(object sender, System.EventArgs e) {
someCommonLogic();
}
private void button1_Click(object sender, System.EventArgs e) {
listView1.Items.Add("Item" + (listView1.Items.Count + 1).ToString());
}
|
|
|
|
|
I know there is a PerformClick for button, is there something not like that for other events ?
|
|
|
|
|
My understanding is that PerformClick exists essentially so that keyboard actions like "ESC" and "Enter" can invoke a button. In general terms, I believe you are looking for more information on Events and Delegates. In other words, you can define your own events and methods with the correct signature that are "bound" to those events as handlers. Although somewhat complex, there is documentation in MSDN and the .NET Framework to understand how you can pursue this further. You might try this[^] as a starting point.
|
|
|
|
|
Hi,
Can anybody help me find an asp.net forum in c# that is totaly free, simple, easy, use sql server, only one projectfile with code behind and supports the older version of visual studio.net.
I have tested about 8 different versions now and i'm still searching.
Yours sincerely
Andla
|
|
|
|
|
|
I believe i have seen all of them. Most of them are not even free.
|
|
|
|
|
Hi again. Well, you may be asking for a lot for free.
Andrlage wrote:
asp.net forum in c# that is totaly free, simple, easy, use sql server, only one projectfile with code behind and supports the older version of visual studio.net
It may be worth paying the money for a well-done commercial product, or to hire a consultant to write exactly what you want. Or it may be worth spending the time to write what you want yourself.
Or - as another alternative, you could download the ASP.NET Community Starter Kit[^]. It's complex, but it may be worth the complexity to have something that's totally free and supports sql server.
I guess the choice you make depends on what you're willing to give to get *most* of what you want (if *all* isn't available).
|
|
|
|
|
Hi there
I need to know if it is possible to record from
the modem using TAPI in C#?
I am making a project that will record conversations
that are going on on the same line as the modem.
Can anyone help me?
VisionTec
|
|
|
|
|
Speaking from a Tapi 2.1 perspective all you really get from Tapi is a handle to a wave device. Above that you really don't record using Tapi, that is done with the MM APIs. I am not sure about newer versions of Tapi. I think the concept is the same but the newer COM based Tapi interfaces use the concept of terminals instead of handles.
Paul Watson wrote:
"At the end of the day it is what you produce that counts, not how many doctorates you have on the wall."
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
|
|
|
|
|
Hey all,
I'm using a POP3 client library (from www.lumisoft.ee) that returns messages as an array of bytes (byte[]).
What I'm looking for is an efficient way to change this array into a string so I can perform Regex functions on it.
I have the following working code, but I don't think it will be very speedy or efficient when processing a large number of messages (or large messages):
<br />
private string messageToString(byte[] message) {<br />
StringBuilder sb = new StringBuilder();<br />
foreach (byte b in message)<br />
sb.Append((char) b);<br />
return sb.ToString();<br />
}<br />
Any suggestions on a better way to do this?
Thanks for your time!
|
|
|
|
|
Look at the System.Text namespace, and in particular classes like ASCIIEncoding class.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
That's just what the doctor ordered.
Thanks much.
|
|
|
|