Refactor
:my
=>
'code'
Codes
Refactorings
Popular
Best
Submit
Spam
Account
Logout
Login
JavaScript doesn't seem to be activated, expect things to be ugly and sloppy!
More Jobs
Recent
Array#split_with(something)
StringExt.cs (String Extension)
showing records in Ascending or Descening order on click
Too many if else if
link_to with an image_tag and text
Ruby Custom Sort
Rails - Multiple instances and folder creation
MySQL original PHP 5 wrapper class
objects that deliver formatted HTML
Easy - descending range
Popular
link_to with an image_tag and text
Too many if else if
showing records in Ascending or Descening order on click
StringExt.cs (String Extension)
Array#split_with(something)
Exercise: Deaf Grandma
Find the Intersection of Arrays with a Hash
two for loops cleanup?
MySQL original PHP 5 wrapper class
Object with Field names as resources
Pastable version of
Pointers in C#
<div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46</pre> <pre class="sunburst"><span style="color:#E28964;">using</span> System; <span style="color:#E28964;">using</span> System.Collections.Generic; <span style="color:#E28964;">using</span> System.Linq; <span style="color:#E28964;">using</span> System.Text; <span style="color:#E28964;">using</span> System.Runtime.InteropServices; <span style="color:#E28964;">namespace</span> Pointers { <span style="color:#E28964;">unsafe</span> <span style="color:#99CF50;">class</span> Program { <span style="color:#E28964;">static</span> <span style="color:#E28964;">unsafe</span> <span style="color:#E28964;">void</span> Main( <span style="color:#99CF50;">string</span>[ ] args ) { Unsafe unsafeObject = <span style="color:#E28964;">new</span> Unsafe( <span style="color:#3387CC;">1</span>, <span style="color:#3387CC;">2</span>, <span style="color:#3387CC;">3</span>, <span style="color:#3387CC;">4</span> ); Console.WriteLine( <span style="color:#65B042;"><span style="color:#65B042;">"</span>FirstLocation[ <span style="color:#65B042;">"</span></span> + unsafeObject.firstLocation->ToString( ) + <span style="color:#65B042;"><span style="color:#65B042;">"</span> ]<span style="color:#DDF2A4;">\n</span><span style="color:#65B042;">"</span></span> + <span style="color:#65B042;"><span style="color:#65B042;">"</span>SecondLocation[ <span style="color:#65B042;">"</span></span> + unsafeObject.secondLocation->ToString( ) + <span style="color:#65B042;"><span style="color:#65B042;">"</span> ]<span style="color:#65B042;">"</span></span> ); Console.Read( ); } } <span style="color:#E28964;">unsafe</span> <span style="color:#99CF50;">struct</span> Unsafe { <span style="color:#E28964;">public</span> Safe* firstLocation, secondLocation; <span style="color:#E28964;">public</span> Unsafe( <span style="color:#99CF50;">int</span> fl_x, <span style="color:#99CF50;">int</span> fl_y, <span style="color:#99CF50;">int</span> sl_x, <span style="color:#99CF50;">int</span> sl_y ) { Safe ffl = <span style="color:#E28964;">new</span> Safe( fl_x, fl_y ), fsl = <span style="color:#E28964;">new</span> Safe( sl_x, sl_y ); <span style="color:#E28964;">this</span>.firstLocation = &ffl; <span style="color:#E28964;">this</span>.secondLocation = &fsl; } } <span style="color:#99CF50;">struct</span> Safe { <span style="color:#E28964;">public</span> <span style="color:#99CF50;">int</span> x, y; <span style="color:#E28964;">public</span> Safe( <span style="color:#99CF50;">int</span> x, <span style="color:#99CF50;">int</span> y ){ <span style="color:#E28964;">this</span>.x = x; <span style="color:#E28964;">this</span>.y = y; } <span style="color:#E28964;">public</span> <span style="color:#E28964;">override</span> <span style="color:#99CF50;">string</span> ToString( ) { <span style="color:#E28964;">return</span> <span style="color:#E28964;">this</span>.x + <span style="color:#65B042;"><span style="color:#65B042;">"</span>,<span style="color:#65B042;">"</span></span> + <span style="color:#E28964;">this</span>.y; } } } </pre> </div> </div> <div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <span style="margin:0;padding:4px 6px;font-size:12px;float:right;">Expected output</span> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2 3</pre> <pre class="sunburst">FirstLocation[ <span style="color:#3387CC;">1</span>,<span style="color:#3387CC;">2</span> ] SecondLocation[ <span style="color:#3387CC;">3</span>,<span style="color:#3387CC;">4</span> ] </pre> </div> </div> <div style="overflow:auto;border:solid 1px #ccc;background:#000;color:#F8F8F8"> <div class="section"> <span style="margin:0;padding:4px 6px;font-size:12px;float:right;">Given output</span> <pre style="float:left;margin:0 10px;border-right:0;color:#666;">1 2</pre> <pre class="sunburst">FirstLocation[ <span style="color:#3387CC;">14</span>,<span style="color:#3387CC;">67169456</span> ] SecondLocation[ <span style="color:#3387CC;">19593296</span>,<span style="color:#3387CC;">19593248</span> ] </pre> </div> </div> <a href="http://refactormycode.com/codes/291-pointers-in-c" style="color:#fff" title="As seen on RefactorMyCode.com"><img alt="Small_logo" src="http://refactormycode.com/images/small_logo.gif" style="border:0" /></a>