Passing objects by reference vs value

前端 未结 3 828
后悔当初
后悔当初 2020-12-03 06:11

I just want to check my understanding of C#\'s ways of handling things, before I delve too deeply into designing my classes. My current understanding is that:

3条回答
  •  再見小時候
    2020-12-03 06:24

    Tragically, there is no way to pass an object by value in C# or VB.NET. I suggest instead you pass, for example, New Class1(Object1) where Object1 is an instance of Class1. You will have to write your own New method to do this but at least you then have an easy pass-by-value capability for Class1.

提交回复
热议问题