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.
comments powered by Disqus
Upcoming Events

.NET Insight

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.