>>> static class Test_RefOut >>> { >>> internal static void Go() >>> { >>> Dictionary<string, string> dict = null; >>> >>> int x = GetDictByRef(ref dict); >>> >>> Console.WriteLine("result : {0}", dict); >>> } >>> >>> static int GetDictByRef(ref Dictionary<string, string> dict) >>> { >>> //dict = new Dictionary<string, string>(); >>> return 2; >>> } >>> >>> } >>>True. OK - back to message 1583810:
public struct LotsOfDoubles >> { >> public double a, b, c, d, e, f, g, h, i, j; >> }>
> public struct LotsOfDoubles > { > public double a, b, c, d, e, f, g, h, i, j; > } > > static class Test_RefOut > { > internal static void Go() > { > LotsOfDoubles lod = new LotsOfDoubles(); > > > int x = GetLotsOfDoublesByRef(ref lod); > > Console.WriteLine("result : {0}", lod); > } > > static int GetLotsOfDoublesByRef(ref LotsOfDoubles lod) > { > lod = new LotsOfDoubles(); > lod.a = 1.4; > lod.b= 1.4; > lod.c = 1.4; > lod.d = 1.4; > lod.e = 1.4; > lod.f = 1.4; > lod.g = 1.4; > lod.h = 1.4; > lod.i = 1.4; > lod.j = 1.4; > > //dict = new Dictionary<string, string>(); > return 2; > } > > } >>
>So, > for each field > load the address of the struct on the stack > load a constant (1.4 here) on the stack > store the constant in field x > > >.method private hidebysig static int32 GetLotsOfDoublesByRef(valuetype GregoryAdam.Test.Tests.LotsOfDoubles& lod) cil managed >{ > // Code size 164 (0xa4) > .maxstack 2 > .locals init ([0] int32 CS$1$0000) > IL_0000: nop > IL_0001: ldarg.0 > IL_0002: initobj GregoryAdam.Test.Tests.LotsOfDoubles > IL_0008: ldarg.0 > IL_0009: ldc.r8 1.3999999999999999 > IL_0012: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::a > IL_0017: ldarg.0 > IL_0018: ldc.r8 1.3999999999999999 > IL_0021: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::b > IL_0026: ldarg.0 > IL_0027: ldc.r8 1.3999999999999999 > IL_0030: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::c > IL_0035: ldarg.0 > IL_0036: ldc.r8 1.3999999999999999 > IL_003f: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::d > IL_0044: ldarg.0 > IL_0045: ldc.r8 1.3999999999999999 > IL_004e: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::e > IL_0053: ldarg.0 > IL_0054: ldc.r8 1.3999999999999999 > IL_005d: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::f > IL_0062: ldarg.0 > IL_0063: ldc.r8 1.3999999999999999 > IL_006c: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::g > IL_0071: ldarg.0 > IL_0072: ldc.r8 1.3999999999999999 > IL_007b: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::h > IL_0080: ldarg.0 > IL_0081: ldc.r8 1.3999999999999999 > IL_008a: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::i > IL_008f: ldarg.0 > IL_0090: ldc.r8 1.3999999999999999 > IL_0099: stfld float64 GregoryAdam.Test.Tests.LotsOfDoubles::j > IL_009e: ldc.i4.2 > IL_009f: stloc.0 > IL_00a0: br.s IL_00a2 > IL_00a2: ldloc.0 > IL_00a3: ret >} // end of method Test_RefOut::GetLotsOfDoublesByRef >Oh well, another argument bites the dust :-}