Re: 'References' (pointers) in C# (without using unsafe)

From: Magnus Lidbom (magnus_lidbom_at_hotmail.com)
Date: 02/05/04


Date: Thu, 05 Feb 2004 11:07:31 +0100

On Thu, 05 Feb 2004 04:00:48 -0500, _ed_ <_nomail@_nospam.com> wrote:

>I'd like to build a class or struct composed of pointers to variables.
>Does this require dropping into an 'unsafe' block, or is there a
>trick?
>
> ....
> int value1 = 1234;
> bool value2 = false;
> string value3 = "Hello Detroit";
>
> public class x {
> int *adr_value1 = &value1;
> bool *adr_value2 = &value2;
> string *adr_value3 = &value3;
> }

Why exactly do you feel you need pointers? What's wrong with
references for what you intend?

/Magnus Lidbom



Relevant Pages

  • Managed C# and Unsafe Code
    ... First, when using unsafe code and pointers, what is the C# equivalent to the ... five derived classes from one base. ... The "base" class for the other functions is an "unsafe ... public class", but when iI try to call a pointer to this class in a function ...
    (microsoft.public.dotnet.languages.csharp)
  • References (pointers) in C# (without using unsafe)
    ... I'd like to build a class or struct composed of pointers to variables. ... Does this require dropping into an 'unsafe' block, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: References (pointers) in C# (without using unsafe)
    ... >>I'd like to build a class or struct composed of pointers to variables. ... >>Does this require dropping into an 'unsafe' block, ... It needs to react like a pointer for any data type-- ...
    (microsoft.public.dotnet.languages.csharp)
  • What I dont like about C# so far, compared to C++ (managed or otherwise)
    ... and am using .NET Visual Studio 2005 ... 1/ no pointers or tracking pointers or handles--this is absurd. ... change the contents of the array, or can't change the Foo instances ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What I dont like about C# so far, compared to C++ (managed or otherwise)
    ... 1/ no pointers or tracking pointers or handles--this is absurd. ... const int wheel = 4). ... change the contents of the array, or can't change the Foo instances ...
    (microsoft.public.dotnet.languages.csharp)