No we should not support enum types derived from strings
12345swordy
alexanderheistermann at gmail.com
Wed May 12 19:11:51 UTC 2021
On Wednesday, 12 May 2021 at 02:30:50 UTC, deadalnix wrote:
> On Wednesday, 12 May 2021 at 02:21:06 UTC, 12345swordy wrote:
>> Yes. A is being replace with the new instance of A that
>> happens to have the same value here. There is no guarantee
>> that they will share the same address.
>>
>> - Alex
>
> You might want to reconsider how sure of yourself you are. For
> instance by opening https://replit.com/languages/csharp and
> running the following code in there:
>
> using System;
>
> class A {
> int i;
> public A(int i_) { i = i_; }
> public int getI() { return i; }
> }
>
> class Program {
> static void Main(string[] args) {
> A a = new A(15);
> Console.WriteLine(a.getI());
> foo(a);
> Console.WriteLine(a.getI());
> }
>
> static void foo(A ainfoo) {
> ainfoo = new A(23);
> Console.WriteLine(ainfoo.getI());
> }
> }
You are conflicting passing an argument by value/reference with
the concept of value/reference types. They are not the same thing.
"Don't confuse the concept of passing by reference with the
concept of reference types. The two concepts are not the same. A
method parameter can be modified by ref regardless of whether it
is a value type or a reference type. There is no boxing of a
value type when it is passed by reference."
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/ref
-Alex
More information about the Digitalmars-d
mailing list