In .Net, pass-by-reference or by-value is a feature of the
type itself. If you want to be able to get references to an object, you need to make its type a
class, not a struct (which is a value type).
In this case MyClass needs to be a class:
class MyClass {
int id;
}
and you need to just return something of type MyClass:
List<MyClass> list;
MyClass find(int id){
foreach(MyClass item in list)
if(item.id == id) return item;
return null;
}
Note that you don't actually have to write this at all, though, if you're in .Net 3.5 or 4, because you can use System.Linq extension methods to write
MyClass theOneIWant = list.FirstOrDefault(c => c.id == id);