{"id":3755,"date":"2014-03-30T05:21:45","date_gmt":"2014-03-30T05:21:45","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/change-property-type-using-reflection-collection-of-common-programming-errors\/"},"modified":"2014-03-30T05:21:45","modified_gmt":"2014-03-30T05:21:45","slug":"change-property-type-using-reflection-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/change-property-type-using-reflection-collection-of-common-programming-errors\/","title":{"rendered":"Change property type using reflection-Collection of common programming errors"},"content":{"rendered":"<p>I have a decimal Value property in my domain class:<\/p>\n<pre><code>public class Domain\n{\n   public decimal Value {get;set}\n}\n<\/code><\/pre>\n<p>I need to assign that Value property with two database values:<\/p>\n<pre><code>obj1.Value = decimal.Parse(reader[\"Value\"].ToString());\nobj2.Value = decimal.Parse(reader[\"Value2\"].ToString());\n<\/code><\/pre>\n<p>Than i have a comparer method wich compare these two properties:<\/p>\n<pre><code>public void Compare(List Domains)\n{\n     \/\/get properties with reflection\n\n     \/\/if the properties values are different i need to set a 'string' value [DIFFERENT]           to it.       \n     prop.SetValue(comparableObj, \"[DIFFERENT]\", null);\n}\n<\/code><\/pre>\n<p>Is it possible to do?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have a decimal Value property in my domain class: public class Domain { public decimal Value {get;set} } I need to assign that Value property with two database values: obj1.Value = decimal.Parse(reader[&#8220;Value&#8221;].ToString()); obj2.Value = decimal.Parse(reader[&#8220;Value2&#8221;].ToString()); Than i have a comparer method wich compare these two properties: public void Compare(List Domains) { \/\/get properties with [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3755","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3755","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3755"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3755\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3755"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3755"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3755"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}