Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361368
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:08:39+00:00 2026-05-18T03:08:39+00:00

Maybe this is a n00bish question, but I’m used to c++’s pointers and references

  • 0

Maybe this is a n00bish question, but I’m used to c++’s pointers and references and this is confusing me a bit. Let’s say I have the following scenario in a VB.net application:

Dim x As New Dictionary(Of String, MyType)
'I add stuff to x
Dim y As MyObject= x("foo1")
'later...
y = New MyType()
'now y and x("foo1") don't point to the same instance anymore

The situation is this: I have a collection of objects, and during execution of the program, any of them can be fetched from the collection to be used/edited by another part of the program. Now obviously if I edit the data inside the object it is allright, but what if I want to replace the object, as I did above at line 5? I would change only the local reference (y) but not the object inside the collection! Is there a way around this? How can I take with me a “reference to the object’s reference”, instead of just a reference, so if I reassign it it will also reassign the one in the collection? I hope I’m making myself clear, unfortunately english is not my native language, to be clear: in c++ this would be easy using a pointer to a pointer, or passing a pointer to the object always by reference, so calling new or reassignment on it would change the original pointer itself)

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:08:39+00:00Added an answer on May 18, 2026 at 3:08 am

    You cannot use pointers in VB.NET (or C#, except through unsafe code).

    Instead, to change the original value in the dictionary that you’ve assigned to y, you need to access it again through the dictionary object itself, rather than through an excised reference:

    x("foo1") = New MyType()
    

    The reason is that the value at the specified location in the dictionary (“foo1”) is assigned to y, not a reference to the location itself in the dictionary. I’m not really sure why you’re using the DataObject class, but y will hold a value of type MyType when it is assigned in your code. Assigning a new value to y will only change the value of y, not the original value in the dictionary. It has no knowledge of that value. Think of it essentially as if you’re pulling a copy of the value out of the dictionary and placing it in the y variable. There’s no way to copy a reference to the page in the dictionary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Maybe this is a dumb question, but I have the following behavior in Visual
I know this maybe a very basic question but I'm having a bit of
Maybe this is a dumb question, but is there any way to convert a
Maybe this is an easy question, maybe not. I have a select box where
This maybe a stupid question, but as I can not easily undo my change
I know this maybe a basic question but I just can't seem to find
Maybe this applied to other Delphi's (I've only used 7). We've got our code
Maybe this is an overarching question as I've seen similar bugs in Firefox and
Maybe this cannot be done, but please help or suggest how this can be
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.