Click here to Skip to main content
15,895,537 members
Home / Discussions / C#
   

C#

 
GeneralRe: Email without an smtp server Pin
led mike9-Oct-06 11:47
led mike9-Oct-06 11:47 
QuestionHow do I capture packets sent to a specific application? Pin
Igor Lima9-Oct-06 3:26
Igor Lima9-Oct-06 3:26 
AnswerRe: How do I capture packets sent to a specific application? Pin
aamironline9-Oct-06 5:15
aamironline9-Oct-06 5:15 
QuestionZooming out image is very slow - multithreading ?? Pin
abcxyz829-Oct-06 3:11
abcxyz829-Oct-06 3:11 
AnswerRe: Zooming out image is very slow - multithreading ?? Pin
lmoelleb9-Oct-06 4:36
lmoelleb9-Oct-06 4:36 
GeneralRe: Zooming out image is very slow - multithreading ?? Pin
abcxyz829-Oct-06 5:25
abcxyz829-Oct-06 5:25 
QuestionHow to program WMI using C# Pin
drypz9-Oct-06 2:21
drypz9-Oct-06 2:21 
QuestionHelp modifying an instance Pin
Andym.Knight9-Oct-06 1:46
Andym.Knight9-Oct-06 1:46 
Hi all,
Im baffled by some code Ive written and need some help.
I have a simple class which holds a property:
<br />
    public class Person<br />
    {<br />
        private string myName = string.Empty;<br />
<br />
        public string MyName<br />
        {<br />
            get { return myName; }<br />
            set { myName = value; }<br />
        }<br />
<br />
        public Person(string name)<br />
        {<br />
            myName = name;<br />
        }<br />
<br />
    }<br />


And I have another class, which is pretty self explanatry:
<br />
    public class Depoll<br />
    {<br />
        public static void NewName(Person obj, string newName)<br />
        {<br />
            obj.MyName = newName;<br />
        }<br />
    }<br />


And finally, here are my tests:
<br />
        [Test]<br />
        public void TestChangeName()<br />
        {<br />
            Person me = new Person("Andy");<br />
            Depoll.NewName(me, "Bill");<br />
            Assert.AreEqual("Bill", me.MyName);<br />
        }<br />


I dont understand why my test passes.
When I provide the Depoll.NewName function with my object, I assume that Im passing an instance. Therefore, any change to that object, will not affect the original, unless the Depoll.NewName returns it.

The Depoll.NewName function doesnt return the object once its been changed, therefore my original object should still have a name property of "Andy".

Can anyone help explain this?

Regards


Andy
AnswerRe: Help modifying an instance Pin
J4amieC9-Oct-06 2:42
J4amieC9-Oct-06 2:42 
GeneralRe: Help modifying an instance Pin
Andym.Knight9-Oct-06 2:45
Andym.Knight9-Oct-06 2:45 
GeneralRe: Help modifying an instance Pin
J4amieC9-Oct-06 4:01
J4amieC9-Oct-06 4:01 
GeneralRe: Help modifying an instance Pin
S. Senthil Kumar9-Oct-06 4:36
S. Senthil Kumar9-Oct-06 4:36 
Questionhi,how can i get XML node name Pin
premkamalg9-Oct-06 1:25
premkamalg9-Oct-06 1:25 
AnswerRe: hi,how can i get XML node name Pin
S. Senthil Kumar9-Oct-06 4:40
S. Senthil Kumar9-Oct-06 4:40 
QuestionGeting the results of a MySQL queiry Pin
Anthony Mushrow9-Oct-06 1:20
professionalAnthony Mushrow9-Oct-06 1:20 
AnswerRe: Geting the results of a MySQL queiry Pin
Anthony Mushrow9-Oct-06 4:29
professionalAnthony Mushrow9-Oct-06 4:29 
Questionreading remote registries Pin
RanjithLogics9-Oct-06 0:27
RanjithLogics9-Oct-06 0:27 
QuestionExcel Pin
Gammaza9-Oct-06 0:19
Gammaza9-Oct-06 0:19 
QuestionLinkLabel1 Pin
Support1238-Oct-06 23:57
Support1238-Oct-06 23:57 
AnswerRe: LinkLabel1 Pin
Andrei Ungureanu9-Oct-06 0:05
Andrei Ungureanu9-Oct-06 0:05 
GeneralRe: LinkLabel1 Pin
Support1239-Oct-06 0:06
Support1239-Oct-06 0:06 
GeneralRe: LinkLabel1 Pin
liuqm.china9-Oct-06 2:46
liuqm.china9-Oct-06 2:46 
GeneralRe: LinkLabel1 Pin
Support1239-Oct-06 2:52
Support1239-Oct-06 2:52 
Questionhow to create program stock product with barcode (c#) Pin
isis_preaw8-Oct-06 23:30
isis_preaw8-Oct-06 23:30 
AnswerRe: how to create program stock product with barcode (c#) Pin
liuqm.china9-Oct-06 2:54
liuqm.china9-Oct-06 2:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.