Let me use the following example to explain my question:
public string ExampleFunction(string Variable) {
return something;
}
string WhatIsMyName = "
GateKiller, what's wrong with my workaround? You could rewrite your function trivially to use it (I've taken the liberty to improve the function on the fly):
static string sMessages(Expression>> aMessages) {
var messages = aMessages.Compile()();
if (messages.Count == 0) {
return "";
}
StringBuilder ret = new StringBuilder();
string sType = ((MemberExpression)aMessages.Body).Member.Name;
ret.AppendFormat("", sType);
foreach (string msg in messages) {
ret.Append(msg);
ret.Append("
");
}
ret.Append("
");
return ret.ToString();
}
Call it like this:
var errors = new List() { "Hi", "foo" };
var ret = sMessages(() => errors);