Class VS ref Struct

后端 未结 2 1726
温柔的废话
温柔的废话 2021-02-09 01:15

I am programming a game using C#, thus, I am very concerned about performance.

I would like to know what are the main differences, and if possible, performance considera

2条回答
  •  抹茶落季
    2021-02-09 01:36

    Your delegate receives a reference type - a List, so you're passing the entire list by reference anyway.

    Passing a large structure by value is definitely most expensive than passing just the reference. When you have a large structure, it usually doesn't make sense to use it as a structure, just turn it into a class.

    Anyway, are you sure you'll have a performance issue here? Seems like a very premature optimization.

提交回复
热议问题