What is the difference between a reference type and value type in c#?

后端 未结 14 2424
谎友^
谎友^ 2020-11-21 05:13

Some guy asked me this question couple of months ago and I couldn\'t explain it in detail. What is the difference between a reference type and a value type in C#?

I

14条回答
  •  醉话见心
    2020-11-21 06:02

    value data type and reference data type

    1) value( contain the data directly ) but reference ( refers to the data )

    2) in value( every variable has its own copy) but
    in reference (more than variable can refer to some objects)

    3) in value (operation variable can`t effect on other variable ) but in reference (variable can affect other )

    4) value types are(int, bool, float) but reference type are (array , class objects , string )

提交回复
热议问题