D
Dan Holmes
If i have two projects (A and B), will the use of a constant in A that was created in B cause a "get" method to be
created to get the constant or will have just have the value? I think the latter because i compiled the below into
different assemblies and then decompiled them with .netreflector.
The below is the IL. i am not good at reading IL but i don't see a method call in here anywhere. I guess this brings
up the point. If i change B's constant but don't recompile A, how does a get the new value? Maybe i am missing
something...
..class public auto ansi beforefieldinit SqlAuthenticate
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
.maxstack 8
L_0000: ldarg.0
L_0001: ldc.i4.0
L_0002: conv.i8
L_0003: stfld int64 Authenticate.SqlAuthenticate::_authenticationMode
L_0008: ldarg.0
L_0009: call instance void [mscorlib]System.Object::.ctor()
L_000e: nop
L_000f: nop
L_0010: ldarg.0
L_0011: ldc.i4.3
L_0012: conv.i8
L_0013: stfld int64 Authenticate.SqlAuthenticate::_authenticationMode
L_0018: nop
L_0019: ret
}
.field private int64 _authenticationMode
}
namespace StaticConstants
{
public static class SqlServerAutenticationModes
{
public const long SqlServer = 1;
public const long Windows = 2;
public const long Mixed = 3;
}
}
namespace Authenticate
{
public class SqlAuthenticate
{
private long _authenticationMode = 0;
public SqlAuthenticate()
{
_authenticationMode = StaticConstants.SqlServerAutenticationModes.Mixed;
}
}
}
dan
created to get the constant or will have just have the value? I think the latter because i compiled the below into
different assemblies and then decompiled them with .netreflector.
The below is the IL. i am not good at reading IL but i don't see a method call in here anywhere. I guess this brings
up the point. If i change B's constant but don't recompile A, how does a get the new value? Maybe i am missing
something...
..class public auto ansi beforefieldinit SqlAuthenticate
extends [mscorlib]System.Object
{
.method public hidebysig specialname rtspecialname instance void .ctor() cil managed
{
.maxstack 8
L_0000: ldarg.0
L_0001: ldc.i4.0
L_0002: conv.i8
L_0003: stfld int64 Authenticate.SqlAuthenticate::_authenticationMode
L_0008: ldarg.0
L_0009: call instance void [mscorlib]System.Object::.ctor()
L_000e: nop
L_000f: nop
L_0010: ldarg.0
L_0011: ldc.i4.3
L_0012: conv.i8
L_0013: stfld int64 Authenticate.SqlAuthenticate::_authenticationMode
L_0018: nop
L_0019: ret
}
.field private int64 _authenticationMode
}
namespace StaticConstants
{
public static class SqlServerAutenticationModes
{
public const long SqlServer = 1;
public const long Windows = 2;
public const long Mixed = 3;
}
}
namespace Authenticate
{
public class SqlAuthenticate
{
private long _authenticationMode = 0;
public SqlAuthenticate()
{
_authenticationMode = StaticConstants.SqlServerAutenticationModes.Mixed;
}
}
}
dan