C# pass by value/ref?

前端 未结 4 1704
借酒劲吻你
借酒劲吻你 2020-12-05 04:58

Common question but I could use an \"english\" explanation.

Is it like Java where

Cat myCat

actually is a pointer to Cat

4条回答
  •  青春惊慌失措
    2020-12-05 05:40

    If you delacred Cat as

    class Cat {...}
    

    then it is.

    If you delcared Cat as

    struct Cat {...}
    

    then your variable "is" the structure itself.

    This is the difference between reference types and value types in .Net.

提交回复
热议问题