D
DonJefe
I am getting a strange message from serialization, and I cannot figure
out what I am doing wrong:
I have a class:
[Serializable]
public class Foobar
{
public Foobar () {}
public Func<Foobar, string> NameFunction
{
get;
set;
}
public string LastName { get; set;}
public string FirstName { get; set;}
public string DisplayName
{
get
{
if (NameFunction != null)
return NameFunction.Invoke(this);
else
return String.Format("{0},{1}", LastName, FirstName);
}
}
}
When I try to serialize this class, I get an error message saying
".... cannot be serialized because it does not have a parameterless
constructor". Clearly, class Foobar has a parameterless constructor,
so this cannot be the case. Is there any way to get around this? Is it
not possible to serialize this type of delegate? Is this an impossible
task?
Thanks.
out what I am doing wrong:
I have a class:
[Serializable]
public class Foobar
{
public Foobar () {}
public Func<Foobar, string> NameFunction
{
get;
set;
}
public string LastName { get; set;}
public string FirstName { get; set;}
public string DisplayName
{
get
{
if (NameFunction != null)
return NameFunction.Invoke(this);
else
return String.Format("{0},{1}", LastName, FirstName);
}
}
}
When I try to serialize this class, I get an error message saying
".... cannot be serialized because it does not have a parameterless
constructor". Clearly, class Foobar has a parameterless constructor,
so this cannot be the case. Is there any way to get around this? Is it
not possible to serialize this type of delegate? Is this an impossible
task?
Thanks.