Is passing a struct value to a method by-reference in C# an acceptable optimization?
Posted
by Arc
on Stack Overflow
See other posts from Stack Overflow
or by Arc
Published on 2010-05-25T16:12:43Z
Indexed on
2010/05/25
16:21 UTC
Read the original article
Hit count: 176
Say I have a struct:
struct MyStruct
{
public int X
public int Y
}
And a method in some class that is iterated over many times elsewhere:
public bool MyMethod( MyStruct myStruct )
{
return ...
}
Is changing the MyMethod signature to the following an acceptable optimization?
public bool MyMethod( ref MyStruct myStruct )
If so, how much of an advantage would it really be? If not, about how many fields would a struct need for a big enough advantage using ref
this way?
© Stack Overflow or respective owner