C# Corner Listing #2: Grab the Result String (C#)
public class HelperClass
{
private readonly string resultFromCalculation;
public HelperClass()
{
resultFromCalculation = reallyLongCalculation();
}
public string Result
{
get { return resultFromCalculation; }
}
}
Listing 2: This implementation eagerly grabs the result string whenever a new object is initialized. It’s a simple implementation, and it’s easy to enforce the immutability of the types.