Use of const in a method
        Posted  
        
            by kouPhax
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by kouPhax
        
        
        
        Published on 2010-03-13T15:53:39Z
        Indexed on 
            2010/03/13
            16:05 UTC
        
        
        Read the original article
        Hit count: 232
        
In the following method,
public void InspectList(IList<int> values)
{
    if(values != null)
    {
        const string format = "Element At {0}";
        foreach(int i in values)
        {
            Log(string.Format(format, i));
        }
    }   
}
Does the use of const provide any benefit over just declaring the string as a string? Woudl it not be interned anyway?
© Stack Overflow or respective owner