Click here to Skip to main content
15,907,906 members
Home / Discussions / C#
   

C#

 
GeneralRe: C# Web Service with Oracle Pin
Chris Meech30-Jan-04 9:11
Chris Meech30-Jan-04 9:11 
QuestionNetwork or graph layout algorithms? Pin
Fernandes27-Jan-04 6:58
Fernandes27-Jan-04 6:58 
AnswerRe: Network or graph layout algorithms? Pin
Nick Parker27-Jan-04 7:09
protectorNick Parker27-Jan-04 7:09 
GeneralRe: Network or graph layout algorithms? Pin
Fernandes27-Jan-04 7:38
Fernandes27-Jan-04 7:38 
Generalref class member variable Pin
pankajdaga27-Jan-04 6:47
pankajdaga27-Jan-04 6:47 
GeneralRe: ref class member variable Pin
John Fisher27-Jan-04 6:51
John Fisher27-Jan-04 6:51 
GeneralRe: ref class member variable Pin
pankajdaga27-Jan-04 7:08
pankajdaga27-Jan-04 7:08 
GeneralRe: ref class member variable Pin
John Fisher27-Jan-04 7:28
John Fisher27-Jan-04 7:28 
Are you trying to make m_i into a pointer to i? If so, then I understand what you're trying to do.

In explanation, the code is taking the value if i and assigning it to m_i, then taking the value of 10 and assigning it to m_i. The attempt to make m_i into a pointer to i is where your expectations have met the problem.

In C#, all class objects are handled "by reference". In other words, every time you to a "new Test()", you are getting a pointer to the real object. This means that whenever you put "myvar = something", you are setting pointers -- NOT copying objects. (Copy constructors only come into play when you explicitly use the "new" keyword.)

That said, you may already have a better technique to achieve your goal. However, you could do something like this:

public class Storage
{
    int value;
}

public class Test
{
    public Test(Storage val)
    {
        m_val = val;
        m_val.value = 10;
    }
    private Storage m_val;
}



John

"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.

GeneralRe: ref class member variable Pin
pankajdaga27-Jan-04 8:22
pankajdaga27-Jan-04 8:22 
GeneralRe: ref class member variable Pin
Heath Stewart27-Jan-04 8:45
protectorHeath Stewart27-Jan-04 8:45 
GeneralRe: ref class member variable Pin
Nick Parker27-Jan-04 6:54
protectorNick Parker27-Jan-04 6:54 
GeneralRe: ref class member variable Pin
pankajdaga27-Jan-04 7:11
pankajdaga27-Jan-04 7:11 
GeneralRe: ref class member variable Pin
Nick Parker27-Jan-04 7:28
protectorNick Parker27-Jan-04 7:28 
GeneralWebSvcs vs Remoting Pin
Kant27-Jan-04 6:24
Kant27-Jan-04 6:24 
GeneralRe: WebSvcs vs Remoting Pin
Heath Stewart27-Jan-04 6:36
protectorHeath Stewart27-Jan-04 6:36 
GeneralRe: WebSvcs vs Remoting Pin
Kant27-Jan-04 6:47
Kant27-Jan-04 6:47 
GeneralRe: WebSvcs vs Remoting Pin
Uwe Keim28-Jan-04 3:11
sitebuilderUwe Keim28-Jan-04 3:11 
GeneralCustom controls Pin
Radoslav Bielik27-Jan-04 6:01
Radoslav Bielik27-Jan-04 6:01 
GeneralRe: Custom controls Pin
John Fisher27-Jan-04 6:54
John Fisher27-Jan-04 6:54 
GeneralRe: Custom controls Pin
Radoslav Bielik27-Jan-04 6:57
Radoslav Bielik27-Jan-04 6:57 
GeneralRe: Custom controls Pin
John Fisher27-Jan-04 7:12
John Fisher27-Jan-04 7:12 
GeneralRe: Custom controls Pin
Radoslav Bielik27-Jan-04 7:26
Radoslav Bielik27-Jan-04 7:26 
GeneralRe: Custom controls Pin
John Fisher27-Jan-04 7:37
John Fisher27-Jan-04 7:37 
GeneralRe: Custom controls Pin
Radoslav Bielik27-Jan-04 7:45
Radoslav Bielik27-Jan-04 7:45 
GeneralRe: Custom controls Pin
John Fisher27-Jan-04 12:44
John Fisher27-Jan-04 12:44 

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.