{"id":4884,"date":"2014-03-30T16:25:43","date_gmt":"2014-03-30T16:25:43","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/which-method-am-i-in-collection-of-common-programming-errors\/"},"modified":"2014-03-30T16:25:43","modified_gmt":"2014-03-30T16:25:43","slug":"which-method-am-i-in-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/which-method-am-i-in-collection-of-common-programming-errors\/","title":{"rendered":"Which Method Am I In?-Collection of common programming errors"},"content":{"rendered":"<p>If you&#8217;re using .NET 4.5 you can use the <code>CallerMemberName<\/code> attribute:<\/p>\n<pre><code>public static GetCallerMemberName([CallerMemberName]string caller = null)\n{\n    return caller;\n}\n<\/code><\/pre>\n<p>Note that when calling this method you don&#8217;t need to pass anything as an argument &#8211; the C# compiler does the work for you. This also means that you avoid performing reflection at runtime, which makes this method much faster.<\/p>\n<p>Usage:<\/p>\n<pre><code>void DoSomething()\n{\n#if Debug\n    Log(\"Now In \" + GetCallerMemberName());\n#endif\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re using .NET 4.5 you can use the CallerMemberName attribute: public static GetCallerMemberName([CallerMemberName]string caller = null) { return caller; } Note that when calling this method you don&#8217;t need to pass anything as an argument &#8211; the C# compiler does the work for you. This also means that you avoid performing reflection at runtime, [&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-4884","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4884","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=4884"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4884\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4884"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4884"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4884"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}