|
It's pretty simple actually. A shallow copy is when you copy just the references to an object, a deep copy copies the objects themselves. For example
class Foo
{
}
class Bar
{
Foo f;
public Bar ShallowCopy()
{
Bar b = new Bar();
b.f = this.f;
return b;
}
public Bar DeepCopy()
{
Bar b = new Bar();
b.f = f.DeepCopy();
return b;
}
}
The Bar object returned by ShallowCopy and the original Bar object both have the same reference to the Foo object. DeepCopy, as you can see, copies the Foo object itself. Note that if Foo has references to some other objects, then it needs to DeepCopy those also and so on. Basically, DeepCopy recursively copies the entire object graph.
Hope this helps.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
I did know about MemberwiseClone, I deliberately wrote it that way because I thought it explained shallow copying better.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have created three windows services in which two services listening two different logical ports continously and one service capture COM ports. These windows services informs the Main Window Application which is also running in different Application Domain or Window Process space. These services and windows application is created in C# .NET
My Question is that which is the best way to communicate between these Windows Services running on the same machine (locally).
1. DOT NET Remoting Services
2. Message Queues
3. Through Socket
4. Through Database
Reliability and scalibility is the main requirement because this machine act as a server and traffic is very high.
Your co-operation would be highly appreciated.
Thanks
Zeeshan
|
|
|
|
|
I have a ListView Control and I make its width bigger in Resize() Event...
when it get bigger, it gets over the space of my program has before Resizing.
And the last column has broken of its right that over the line of newly added space of my program.
right side of last column is cutted and thown away. but the detailed item is shown precise.
I tried varous value for columnHeader3.Width but it broken again and again.
Of course, I don't mistake the order of resizing the listView and the panel that has it.
Please give me a hand for the solution.
InitializeComponent()......
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.listView1.Alignment = System.Windows.Forms.ListViewAlignment.Default;
this.listView1.BackColor = System.Drawing.Color.Gainsboro;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,this.columnHeader2,this.columnHeader3});
this.listView1.FullRowSelect = true;
this.listView1.GridLines = true;
this.listView1.Location = new System.Drawing.Point(4, 120);
this.listView1.Name = "listView1";
this.listView1.Scrollable = false;
this.listView1.Size = new System.Drawing.Size(190, 50);
this.listView1.TabIndex = 5;
this.listView1.View = System.Windows.Forms.View.Details;
//
// columnHeader1
//
this.columnHeader1.Text = "Name";
this.columnHeader1.Width = 70;
//
// columnHeader2
//
this.columnHeader2.Text = "Grade";
this.columnHeader2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader2.Width = 40;
//
// columnHeader3
//
this.columnHeader3.Text = "Battle";
this.columnHeader3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
this.columnHeader3.Width = 100;
and...my_SizeChanged(object sender, System.EventArgs e)
{
this.listView1.columns[2].Width=-2;
this.columnHeader3.Width=-2;
}
I am going to make it. complete the vision.
|
|
|
|
|
How can I edit existing attribute in xml file.
|
|
|
|
|
For example, you can use XmlDocument . You only need to find your atribute, change its value and save changes with XmlDocument.Save() method. Or you can use XmlReader/XmlWriter combination + temp file to do the same. Which to choose depends on size of XML file. (use XmlReader/XmlWriter for really big files)
Btw you can (should) post this to XML/XSL forum.
David
|
|
|
|
|
I have a windows service and i want it to send a message such as ("i'm processing") when i start doing a function to an application (web or windows app). How can i do that?
Anyone can help me? I'm very need it for my project. Thanks!
|
|
|
|
|
Did you look into .NET remoting? You can host a remote object in your service, get a reference to it in your application and then call the appropriate method on the remote object when you want to send a message.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
.NET remoting? No, i've never heard of that. Thanks your suggestion. I'll try it.
|
|
|
|
|
I have an Open File Dialog, it has the right to open multiple files. How do I determine which file is which? First from second, and then how do I do a different thing with them?
|
|
|
|
|
Something like this?
if (openFileDlg.ShowDialog()==DialogResult.Ok)<br />
{<br />
foreach(string file in openFileDlg.FileNames)<br />
{<br />
MessageBox.Show(file);<br />
}<br />
}
|
|
|
|
|
There is no garantee that the first filename clicked on, or selected, will be the first filename you get in the enumeration of the list. There is no way to deteremine which filename was first with any certainty.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do you get a picture box to display two images overlapping. They would be gifs, so they are transparent.
Example
Green.gif
Rock.gif
Green is a gif that is 50x50 pixels and all green.
Rock is a picture that is transparent and has a small brown circle in the center.
I want the rock to be on the green(Grass)
Thanks for input.
|
|
|
|
|
Ok, I know how to do it. You can make two levels by making one a background, and the other the image.
|
|
|
|
|
Hi, anyone can help me in making COM in C#, i have a inventory system can i convert it into COM, or COM+. please tell me about good web-link or basic steps to foliow. thanks
|
|
|
|
|
|
it seem to be good, to clear the concepts, can u help in coding, or can suggest any coding tutorial,thanks
|
|
|
|
|
Why not search for yourself? There are many articles here on CP showing you how to code COM classes in C#.
mav
|
|
|
|
|
I have an app that creates a panel that has the docking style set to fill (filling up the whole program) and another panel added to the control list of this first panel, which is quite large btw (about 5Kx5K). Now I'm wanting to add little Forms to this larger panel and that seems to work ok. Right now I do "myFrm.Parent = bigPanel" where myFrm is of course a Form() and bigPanel is Panel(), obviously. So I see my form there and can move it around, but once I move the scroll bars which come up from the first panel (AutoScroll set to true) it appears that the form moves around like it should, but it's really not. I can't then move the form around until I do something to the main app that causes a paint, like shake the program around, or resize it, etc. Also when the form "sticks" like this, I can actually click and drag it around if I click where the title bar of the form was BEFORE I scrolled, which usually for me is near the center of the form. This seems quite odd and I'm not sure how to fix it. Maybe somehow I need to update the position of the form when the panel scrolls or something, I'm not really sure. Any one know why this could be happening? You can see it for yourself easily if you re-create a test app how I described to see what I'm talking about if I'm not 100% clear. Thanks!
|
|
|
|
|
Well, you're not supposed to put a Form-derived class as a child window of another form (unless it is a MDI child, which is another story). I don't know why what you do works, but I wouldn't expect it to.
For your situation, if you want a form that can be moved inside another form, try MDI parent/child forms. It will work much better.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I was kind of thinking I needed to do MDI but I thought maybe I could make it work the other way, o well. Thanks though, I'll changed things around so I make use of MDI. Hopefully everything will go smoother now.
|
|
|
|
|
Yes. You could maybe hack up something that could barely work, but MDI is designed exactly for that, so I guess it's a better idea. And the .NET Framework makes it *soo easy* to make your form MDI that it really becomes a very valid option.
Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
can anyone pls help me to explain what is the meaning of the regex
variableSyntax = new Regex("\\w+(\\.\\w+)*[ ](?<variablename>\\w+)\\s*(=|;)");
what's the ?<variablename> meaning???
|
|
|
|
|
Nothing.
You can use it in the meaning of {0,1}: [a-z]?
You can use it to make matches non-greedy: [a-z]*?
You can even use it to make ? in the form of {0,1} non-greedy: [a-z]??
You can use it in several extensions in the form (?x...) where x is any of the characters: iLmsux:P#=!<(
There is however no form where it will appear first in a parenthesis followed by the \ character.
If it is allowed, it has no special meaning, and it will be one of the few cases where it actually matches a question mark without needing to be escaped.
---
b { font-weight: normal; }
|
|
|
|