// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace E { public struct S { public int A; public int B; public int C; public S(int a, int b, int c) { A = a; B = b; C = c; } public override string ToString() { return string.Format("({0},{1},{2})", A, B, C); } } public class Program { public static void M(S v1, ref S v2, out S v3, in S v4) { v1.A = 321; v2.A = 321; // requuired: v3 = new S(); v3.A = 321; // not allowed: //v4.A = 321; } public static void Main(string[] args) { S v1 = new S(123, 456, 789); S v2 = new S(123, 456, 789); S v3 = new S(123, 456, 789); S v4 = new S(123, 456, 789); Console.WriteLine("{0} {1} {2} {3}", v1, v2, v3, v4); M(v1, ref v2, out v3, v4); Console.WriteLine("{0} {1} {2} {3}", v1, v2, v3, v4); } } }