lifetime of local variable inside an Action in c# Lifetime of local variable declared inside a method is limited to the execution of that method. But in the following code sample lifetime of local variable index preserved after the execution of method .  class Program {     static Action action;     static void Main(string[] args)     {         setAction();         for (int i = 0; i &lt; 5; i++)         {              action();         }                     Console.ReadLine();     }      static void setAction()     {         var index = 5;         action = () =&gt; {             index++;             Console.WriteLine("Value in index is {0}",index);         };     } }   The output of the program is this  Value in index is 6 Value in index is 7 Value in index is 8 Value in index is 9 Value in index is 10   I can not understand how the values in variable index is preserved.
What are 'closures' in .NET? What is a closure? Do we have them in .NET?  If they do exist in .NET, could you please provide a code snippet (preferably in C#) explaining it?
Adding Layer Files (.lyr, .lyrx) to QGIS At college we use ArcGIS Desktop 10, but that does not function on my Mac so I have QGIS there instead.  I want to do my exercises with QGIS, but in ArcGIS Desktop we use .lyr files with ArcMap and .lyrx files with ArcGIS Pro, and they are not supported by QGIS.  Does anyone know, how I can connect the *.lyr files to my *.shp files to use them on my Mac with QGIS? Can I install Android on my non-Android device? Many people want to try/use Android without buying a new Android phone.  How can I install Android on my current phone or device running Nokia Symbian, Maemo, or MeeGo; Microsoft Windows Mobile or Windows Phone 7/8/10; Apple iOS (iPhone); RIM's BlackBerry OS; Palm's WebOS; Samsung's Bada; HP's WebOS; Mozilla's Firefox OS; or other phone / operating system? Add layer to a QGIS group using Python I am trying to add new layers into a specific group which I can get to work if I know the index, but how can I get Python to find the index of a group so it can load the new layer into the group wherever it is in the TOC?  qgis.utils.iface.legendInterface().moveLayer( layer, index ) What is "cloning a hard drive" and how does one go about doing it? What does cloning a hard drive mean? Is it just simply copying over all the "CONTENT" of the hard drive EXCLUDING the operating system, drivers, all the installed programs? or is it copying the ENTIRE hard drive BIT for BIT? Is the cloned hard drive bootable?  I have an external USB hard drive and trying to make a exact copy of my computer system by cloning, so that I can connect the cloned hard drive to another machine and boot into it, or install the cloned disk on another computer system and boot into it. Is this possible? Or am I going about this totally wrong?  What is ghosting a hard drive? TP-Link Archer T3U Plus USB adapter Cannot make this wireless adapter work on Ubuntu 20.04... please help. I've tried this:  and now lsusb sees the device, but still doesn't work. lsusb: Bus 002 Device 006: ID 2357:0138 TP-Link 802.11ac NIC uname -r: 5.4.0-39-generic Edit: It works on my other computer with Ubuntu 18.04 using T2U Plus driver from here:  But it does not work with Ubuntu 20.04... sudo modprobe 88x2bu: Gives nothing. modinfo 88x2bu | grep -e version -e 0138 : version:        v5.6.1_30362.20181109_COEX20180928-6a6a srcversion:     9C5282368F93050B7206C8D parm:           rtw_chip_version:int  dmesg | grep 88x2 : [ 8087.334869] 88x2bu: loading out-of-tree module taints kernel. [ 8087.336610] 88x2bu: module verification failed: signature and/or required key missing - tainting kernel [ 8087.341389] usbcore: registered new interface driver rtl88x2bu When I create beamer frame, the content is centred in the slide. How do I make the content move to the top of the slide by default? Why does everything spin? The origin of spin is some what a puzzle to me, everything spin from galaxies to planets to weather to electrons.  Where has all the angular momentum come from? Why is it so natural?  I was also thinking do photons spin? we always think of the wave as a standard 2d sin wave but could this rotate in 3d? What implications would this have?   And what about spacetime how does all the spinning effect?  This has always been avoided in all lectures and classes I ever went to. How should you deal with (deliberate) selective deafness? How to create quizzes with macqtex? How to use SSH to run a local shell script on a remote machine? Im trying to have the bibliography defined for my document using BibTeX and the natbib citation management package. Styles such as unsrtnat give me the references in order of appearance in text. However, I have a problem that I cannot get around. Basically if a reference is supposed to look like:     Tyson J.P. Dikstra M. Holmes F.M.R. Theoretical Analysis on Effect of   Anomalous Low Friction. International journal of Placticity,   34(3-4):413, 1997.   after typesetting it appears as :     Dikstra M. Holmes F.M.R. Tyson J.P. Theoretical Analysis on Effect of   Anomalous Low Friction. International journal of Placticity,   34(3-4):413, 1997.   In other words, it puts the first author in the last place. Is there any method of getting around this?  The entry as it appears in the .bib file (refs.bib) is:  @ARTICLE{Tyson1997, author={Tyson, J.P., Dikstra, M., Holmes, F.M.R.}, title={Theoretical Analysis on Effect of Anomalous Low Friction.}, journal={International journal of Plasticity}, year={1997}, volume={34}, number={3-4}, pages={413}, document_type={Article} }   An excerpt from the tex file:  \usepackage[round,comma]{natbib} \begin{document}  As an alternative method of analysis, \citet{Tyson1997} ...  \bibliographystyle{unsrtnat}  \bibliography{refs}  \end{document} Gaps between arrows and labels Better than premium About multi-root search in Mathematica for transcendental equations MySQL: LEFT JOIN not working as expected I know that for any nonzero $x,y\in\mathbf{R}$,  $$ax^2+by^2+cxy &gt; 0,$$  where $a,b,c\in\mathbf{R}$. What can I deduce about $a$, $b$, and $c$?    For example, letting $x=1$ and $y=0$, I know that $\boxed{a&gt;0}$. Letting $x=0$ and $y=1$, I know that $\boxed{b&gt;0}$. Letting $x=y=1$, I know that $\boxed{c&gt;-(a+b)}$.  What else can I deduce about $a$, $b$, and $c$? How will I know when it's time to stop looking? (Is that last question even answerable?) Altering layer's CRS to correct Layer Misalignment in QGIS I've got a vector layer in my project which isn't aligned with the rest of the project (see attached JPEG).  These are work files so I'm not sure when they were created or how they might have been messed with since they were created.  We moved from ArcGIS to QGIS a couple of years ago.  The infilled blue vector layer is the one I need to move, slightly north and east, so that it correlates to the blue line (also a vector).  All layers (and the project) are currently in EPSG:27700 - OSGB 1936.   If I need to create a new CRS based on OSGB 1936 and give it some new parameters, then how would I go about this?  Further information:  This is on Exmoor in SW England, and the data is uniformly almost exactly 8m out to the SW point to point - i.e I need to shift it 8m NE. There are many documentaries, forums, blogs and more dedicated to . I have been frantically searching for an answer to my question however none of my sources have clarity to the matter of hand. I would really love a clear explanation to: What exactly is Dark Matter? Please help me to have a clear understanding. How to remove images from showing in a post with the_content()? Trying to learn more about creating my own themes and not using any plugins I wanted an ability to display all the images in a post excluding the thumbnail in my single-foobar.php file and I can do that with:  &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post();      $thumb_ID = get_post_thumbnail_id( $post-&gt;ID );  $args = array(    'post_type' =&gt; 'attachment',    'numberposts' =&gt; -1,    'post_status' =&gt; null,    'post_parent' =&gt; $post-&gt;ID,    'exclude' =&gt; $thumb_ID   );  $attachments = get_posts( $args );  if ( $attachments ) {     foreach ( $attachments as $attachment ) {        echo '&lt;div class="portproject"&gt;';        $image_res = wp_get_attachment_image( $attachment-&gt;ID, ' img-responsive' );        echo $image_res;        echo '&lt;/div&gt;';       }  }  else { ?&gt;     &lt;span&gt; No pictures loaded at this time&lt;/span&gt;  &lt;?php } endwhile; endif; ?&gt;   However, when I apply my static HTML and then try to call get_the_content() with:  &lt;?php  $content = get_the_content(); $content = preg_replace("/&lt;img[^&gt;]+\&gt;/i", "(image) ", $content);           $content = apply_filters('the_content', $content); $content = str_replace(']]&gt;', ']]&gt;', $content); echo $content; ?&gt;   it removes the images but leaves a (image) in the post with spaces then displays the remaining text. I did find a similar  but it suggests using get_the_content() but that strips all the styling from the post.  So my question is how can I strip images from the_content()?  I did find "" from my searches but that still uses the get_the_content() approach. How to add programs to the Unity Launcher or Ubuntu Dock? How can I add new programs to the launcher (or the dock in Ubuntu 17.10 and later) in Ubuntu?