{"id":703,"date":"2012-03-29T13:38:28","date_gmt":"2012-03-29T02:38:28","guid":{"rendered":"http:\/\/ntsblog.homedev.com.au\/?page_id=703"},"modified":"2018-07-18T09:58:27","modified_gmt":"2018-07-17T23:58:27","slug":"code-snippets","status":"publish","type":"page","link":"https:\/\/ntsblog.homedev.com.au\/index.php\/code-snippets\/","title":{"rendered":"Code Snippets"},"content":{"rendered":"<div id=\"ntsbl-712008442\" class=\"ntsbl-before-content ntsbl-entity-placement\"><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-6288941070289539\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-6288941070289539\" \ndata-ad-slot=\"9356781486\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div><p>This is just a list of the small code samples that I always seem to forget, and I use this page as a personal reference for those little code snippets.<\/p>\n<h2>string.Split<\/h2>\n<p>string[] values = delimited.Split(new string[] { &#8220;\/&#8221; }, StringSplitOptions.RemoveEmptyEntries);<\/p>\n<h2>DateTime.ToString()<\/h2>\n<p>These are the custom date time formats that I like to use and always forget..<\/p>\n<p>DateTime.Now.ToString(&#8220;dd-MMM-yyyy hh:mm:ss.fff tt&#8221;);<\/p>\n<ul>\n<li>MMM &#8211; Three digit month\n<li>hh &#8211; 12 hour time\n<li>HH &#8211; 24 hour time\n<li>mm &#8211; lower case m&#8217;s for minutes\n<li>fff &#8211; milliseconds\n<li>tt &#8211; AM \/ PM\n<\/ul>\n<p>When using a date for a log entry timestamp I use:<br \/>\nDateTime.Now.ToString(&#8220;yyyy-MM-dd hh:mm:ss&#8221;);<\/p>\n<h2>Access the Registry<\/h2>\n<p>[csharp]<br \/>\nusing Microsoft.Win32;<br \/>\n&#8230;<br \/>\n\/\/ This creates or opens<br \/>\nRegistryKey key = Registry.LocalMachine.CreateSubKey(&quot;\\Sofware\\YourApplication\\YourKey&quot;);<br \/>\n[\/csharp]<\/p>\n<h2>SQL methods<\/h2>\n<ul>\n<li> newid() &#8211; generates a new uniqueidentifier (uuid or guid)\n<li> charindex(searchcriteria, stringtoSearch, [startPosition])\n<li> substring(stringToCheck, startingPos, Length)\n<li> replace( stringToCheck , searchValue , replacementValue )\n<\/ul>\n<h2>C# basics<\/h2>\n<p>Decimal Literal &#8211; 123.45m<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is just a list of the small code samples that I always seem to forget, and I use this page as a personal reference [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"jetpack_post_was_ever_published":false,"footnotes":""},"class_list":["post-703","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/pages\/703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=703"}],"version-history":[{"count":0,"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/pages\/703\/revisions"}],"wp:attachment":[{"href":"https:\/\/ntsblog.homedev.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}