No we should not support enum types derived from strings

12345swordy alexanderheistermann at gmail.com
Wed May 12 02:21:06 UTC 2021


On Wednesday, 12 May 2021 at 02:07:14 UTC, deadalnix wrote:
> On Wednesday, 12 May 2021 at 01:58:39 UTC, 12345swordy wrote:
>> No, classes are reference types, structs are values types in 
>> c#.
>>
>> -Alex
>
> No, both are value type,
Wrong.

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/reference-types

> but in the case of the class, the value contains a reference to 
> the payload that you describe in the class's body. Consider:
>
> class A {}
> A a = new A();
>
> void foo(A ainfoo) {
>     ainfooo = new A();
> }
>
> foo(a);
>
> Was "a" modified here?
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


More information about the Digitalmars-d mailing list