copy an attribute of a property from one instance to another instance (of a different type ) at runt

Posted by Omu on Stack Overflow See other posts from Stack Overflow or by Omu
Published on 2010-06-14T13:57:36Z Indexed on 2010/06/14 14:02 UTC
Read the original article Hit count: 157

Filed under:
|
|

let's say I have 2 classes like this:

public class Foo
{
[Required]
public string Name {get;set;}
}

public class Bar 
{
// put here [Required] at run-time
public string Name {get;set;}
}

var foo = new Foo();
var bar = new Bar();
//copy the required from foo to bar

is it possible to copy the attributes from foo to bar at run-time ?

© Stack Overflow or respective owner

Related posts about c#

Related posts about reflection