Visual Studio 2013:
Anonymous types contain one or more public read-only properties. No
other kinds of class members, such as methods or events, are valid.
The expression that is used to initialize a property cannot be null,
an anonymous function, or a pointer type.
Actually yes you can: MSDN Documentation:
var fName = "First Name";
var lName = "Last Name";
var t = new
{
FirstName = "First Name",
LastName = "Last Name",
FullName = new Func<string>(() => { return fName + lName; })
};
Depending on how badly you want TypeSafety, you could do something like this also:
dynamic v = new ExpandoObject();
v.FirstName = "FName";
v.LastName = "LName";
v.FullName = new Func<string>(() => { return v.FirstName + " " + v.LastName; });
Although honestly, I would probably just create a nested type in the method's parent class with those properties and method. Either would work, and the internal class wouldn't messy up the rest of the project if it's only used in there.