I have a simple problem, but I am having a hard time getting the concept.  I have an array of doubles (doublesarray) and I want to slice the array so that I get the last "x" values.  x could be 2,5,7,12,etc  example:  doublesarray = {0,2,4,5,7,8,2,4,6}; doublesarray.slice(-4,-1);  output: [8,2,4,6]   doublesarray.slice(-2,-1); output: [4,6]   Attempt:  I found some code online that slices, but it does not handle 2 negative inputs.  public static class Extensions {     /// &lt;summary&gt;     /// Get the array slice between the two indexes.     /// ... Inclusive for start index, exclusive for end index.     /// &lt;/summary&gt;     public static T[] Slice&lt;T&gt;(this T[] source, int start, int end)     {         // Handles negative ends.     if (end &lt; 0)     {         end = source.Length + end;     }     int len = end - start;      // Return new array.     T[] res = new T[len];     for (int i = 0; i &lt; len; i++)     {         res[i] = source[i + start];     }     return res;     } }
How do you do it? Given a byte array:  byte[] foo = new byte[4096];   How would I get the first x bytes of the array as a separate array? (Specifically, I need it as an IEnumerable&lt;byte&gt;)  This is for working with Sockets. I figure the easiest way would be array slicing, similar to Perls syntax:  @bar = @foo[0..40];   Which would return the first 41 elements into the @bar array. Is there something in C# that I'm just missing, or is there some other thing I should be doing?  LINQ is an option for me (.NET 3.5), if that helps any.
network manager says "device not managed" When should I use the Visitor Design Pattern? Proper Way to Combine Feature Selection and Hyperparameter Tuning? How to remove zsh alias? banner set interval Divergence of $\frac{ \hat {\bf r}}{r^2} \equiv \frac{{\bf r}}{r^3}$, what is the 'paradox'? I just started in Griffith's Introduction to electrodynamics and I stumbled upon the divergence of $\frac{ \hat r}{r^2} \equiv \frac{{\bf r}}{r^3}$, now from the book, Griffiths says:  Now what is the paradox, exactly? Ignoring any physical intuition behind this (point charge at the origin) how are we supposed to believe that the source of $\vec v$ is concentrated at the origin mathematically? Or are we forced to believe that because there was a contradiction with the divergence theorem? Also how would the situation differ if $\vec v$ was the same vector function but not for a point charge? Or is it impossible? i am making a boss battle for my minecraft adventure map, and using a mob spawned with commands as the boss. When the mob gets hit, some command blocks will give the player a potion effect, but I can't figure out how to activate the command block when the mob gets hit. I am in the latest snapshot (16w03a). please help me (the person who answers my question will be given credit for it in my map) What and where are the stack and heap? Programming language books explain that value types are created on the stack, and reference types are created on the heap, without explaining what these two things are. I haven't read a clear explanation of this.  I understand what a stack is. But,    Where and what are they (physically in a real computer's memory)? To what extent are they controlled by the OS or language run-time? What is their scope? What determines the size of each of them? What makes one faster? How to link a variable of a material to another material? If "No One" uses a face from the Hall of Faces to become someone then how did he do this Use induction to prove the following: $1! + 2! + .... + n! &lt; (n + 1)!$  Base case:  $n = 1$  $1! &lt; 2!$ true   Inductive step: Assume that $1! + 2! + .... + k! \le  (k + 1)!$ is true   let $n = k + 1$  $1! + 2! + .... + (k + 1)! &lt; (k + 2)!$  $1! + 2! + .... + k! + (k + 1)! &lt; (k + 2)!$  $1! + 2! + .... + k! + (k + 1)! &lt; (k + 2)!$  $(k + 1)! + (k + 1)! &lt; (k + 2)!$  $2(k + 1)! &lt; (k + 2)!$  $2(k + 1)(k)(k - 1).. &lt; (k + 2)(k + 1)(k)(k - 1)....$  $2 &lt; (k + 2)$   the right is always bigger for k are non negative integer. Missing Microsoft.Data.Services.Client version 5.6 on Azure Websites How do I access the index in a for loop like the following?  ints = [8, 23, 45, 12, 78] for i in ints:     print('item #{} = {}'.format(???, i))   I want to get this output:  item #1 = 8 item #2 = 23 item #3 = 45 item #4 = 12 item #5 = 78   When I loop through it using a for loop, how do I access the loop index, from 1 to 5 in this case? Holomorphic functions: is it true that $f(\bar{z})=\overline {f(z)}$? When to capitalize the name of a season Which sentence uses the correct capitalization for the name of the season?     I will travel in the summer of 2013.   or     I will travel in the Summer of 2013. When I'm using  find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt"  it finds all the types of file. But when I add -exec at the end:  find . -type f -name "*.htm*" -o -name "*.js*" -o -name "*.txt" -exec sh -c 'echo "$0"' {} \;  it seems it only prints .txt files. What am I doing wrong?  Note: using MINGW (Git Bash) What are some good tutorials on writing custom styles (classes) that clearly explain commands used and some of the features that TeX has to offer in the way of styles? https:// search results appearing on Google for purely http:// site I started weeding through my site's search results from Google today, using a site: search, to determine if there are any links that cause 404s and thus need redirecting. To my amazement I noticed numerous https:// results relating to various pages. My site doesn't have a SSL certificate, doesn't serve such pages, doesn't internally link to https:// pages, doesn't include any such files in its sitemap.xml and, for all of these, never has.  I decided to do a Google search for https://&lt;my site&gt; and found one site that incorrectly refers to the root of my site with a https:// prefix - I will try to contact them to get them to correct this.  I'm not sure however how Googlebot managed to index the non-root files as https://. I can't find any external links to them and surely, without certification, Googlebot should have stalled at the first request?  I've just added the following lines to the site's .htaccess (although the surfer still has to navigate through the browser's "This site is a security risk. Abandon hope all ye who enter here!" message(s) first to get there):  RewriteEngine On RewriteCond %{HTTPS} on RewriteRule ^(.*)$ http://www.&lt;my site&gt;.org/$1 [R=301,L]    replacing &lt;my site&gt; with my domain name.   My big question is this though - I would like to use the Google Webmaster Tools Remove URLs feature to remove the https:// pages from the index. Can I be guaranteed that this will only remove the https:// versions of each relevant page and not the valid http:// versions?  My thanks to anyone who can help me out with this particular question and the issue in general. Center image element in parent div Applying for a USA B1/B2 Visa for an alien resident in Germany I hold an EU Blue Card and an Indian Passport and have submitted a paper to a conference in the USA due to occur in September 2019. The Blue Card will expire in August 2019 but have already obtained an extension for the same.  In order to present the paper in the conference I need to apply for a B1/B2 visa for the USA and not sure if I may be allowed to apply for one in Germany since I am not a German Citizen.  Are there any specific documents that I might need in order to apply for the B1/B2 Visa since I am not a citizen of the country where I am actually applying?