We are in a situation where we need to use to different sizes of stars (rating) The RenderStars make thats a little harder than it could be.
I suggest we can define our own pictures and classes. And remove the width and height from the element and set it in the class.
And / or maybe some templates.
public static string RenderStars(double Rating) { StringBuilder builder = new StringBuilder(); int num = 1; do { if (Rating >= num) { builder.AppendLine(""); } else if (Rating > (num - 1)) { builder.AppendLine(""); } else { builder.AppendLine(""); } num++; } while (num <= 5); return builder.ToString(); } |