#region getConstant
public static object getConstant(ref string key)
{
object tmpObj;
if ((myCache[constantIdentifier + key] != null))
{
tmpObj = (object)myCache[constantIdentifier + key];
}
else
{
tmpObj = pullConstantFromFile(ref key);
//Create the cache dependencies and insert the object into the cache
if ((tmpObj != null))
{
if (myCache[constantKey] == null)
{
myCache.Insert(constantKey, DateTime.Now);
}
myCache.Insert(constantIdentifier + key, tmpObj, new System.Web.Caching.CacheDependency(applicationConstantsFileName));
}
}
return tmpObj;
}
#endregion
But when I try private static int thisVersion = getConstant("THIS_VERSION"); I get 2 errors:
- The best overloaded method match for 'CM.ConstantsManager.getConstant(ref string)' has some invalid arguments
- Argument '1' must be passed with the 'ref' keyword
Public Shared Function getConstant(ByRef key As String) As Object Dim tmpObj As Object If Not (myCache(constantIdentifier & key) Is Nothing) Then tmpObj = CType(myCache(constantIdentifier & key), Object) Else tmpObj = pullConstantFromFile(key) 'Create the cache dependencies and insert the object into the cache If Not IsNothing(tmpObj) Then If myCache(constantKey) Is Nothing Then myCache.Insert(constantKey, now) End If myCache.Insert(constantIdentifier & key, tmpObj, New CacheDependency(applicationConstantsFileName)) End If End If Return tmpObj End Function
So in my mind the ref keyword in the C# version isn't even necessary, am I correct?
To make things easier this class is being used to read constants from am XML file that can be shared across multiple applications, even Web, all from one XML file so the actual value of "THIS_VERSION" is an integer value
This post has been edited by PsychoCoder: 05 January 2008 - 09:38 AM

New Topic/Question
Reply



MultiQuote





|