I am trying to get  my head around, what happens here ? What sort of code does the compiler produce?  public static void vc() {     var listActions = new List&lt;Action&gt;();      foreach (int i in Enumerable.Range(1, 10))     {         listActions.Add(() =&gt; Console.WriteLine(i));     }      foreach (Action action in listActions)     {         action();     } }  static void Main(string[] args) {    vc(); }   output:  10 10 ..  10  According to , a new instance of ActionHelper would be created for every iteration. So in that case, I would assume it should print 1..10. Can someone give me some pseudo code of what the compiler is doing here ?  Thanks.
I met an interesting issue about C#. I have code like below.  List&lt;Func&lt;int&gt;&gt; actions = new List&lt;Func&lt;int&gt;&gt;();  int variable = 0; while (variable &lt; 5) {     actions.Add(() =&gt; variable * 2);     ++ variable; }  foreach (var act in actions) {     Console.WriteLine(act.Invoke()); }   I expect it to output 0, 2, 4, 6, 8. However, it actually outputs five 10s.  It seems that it is due to all actions referring to one captured variable. As a result, when they get invoked, they all have same output.  Is there a way to work round this limit to have each action instance have its own captured variable?
I'd like to user a FIDO2 key to log into Windows 10. There are various guides explaining how to add a key to a Microsoft web account, or to Windows 10 sign in options, but neither result in showing up as an option when I try logging into Windows.  How can I configure windows to use my FIDO2 key to log in? What should I do before dual-booting Windows 7 and Debian on EFI? What is the default order of records for a SELECT statement in MySQL? Suppose you have the following table and data:  create table t (     k int,     v int,     index k(k)     ) engine=memory;  insert into t (k, v) values (10, 1),        (10, 2),        (10, 3);   When issuing select * from t where k = 10 with no order by clause, how does MySQL sort the records by default? How to run untrusted Ruby code inside a safe sandbox? Waiting for user input with a timeout I have searched but apparently my google foo is weak. What I need is a way to prompt for user input in the console and have the request time out after a period of time and continue executing the script if no input comes in. As near as I can tell, Read-Host does not provide this functionality. Neither does $host.UI.PromptForChoice() nor does $host.UI.RawUI.ReadKey(). Thanks in advance for any pointers.  EDIT: Much thanks to Lars Truijens for finding the answer. I have taken the code that he pointed out and encapsulated it into a function. Note that the way that I have implemented it means there could be up to one second of delay between when the user hits a key and when script execution continues.  function Pause-Host {     param(             $Delay = 1          )     $counter = 0;     While(!$host.UI.RawUI.KeyAvailable -and ($counter++ -lt $Delay))     {         [Threading.Thread]::Sleep(1000)     } } Why, microscopically, is the voltage drop across a resistor affected by the current through it? If voltage is a potential difference, describing how much energy will be lost per unit charge as charge carriers pass through the resistor, why would the rate at which charge flows (i.e. current, $=dq/dt$) affect the amount of energy lost per unit charge?  I suppose I am asking why a quasi-"extensive" property of the system (current) would affect a quasi-"intensive" property of the system (voltage drop across the resistor).  Apologies if the answer is obvious; I was having trouble understanding why the rate of charge flow would factor into voltage drop whilst trying to rationalize Ohm's law for myself. Differences between LuaTeX, ConTeXt and XeTeX I get Chrome notifications from several websites and they work when I don't even have any tabs open for those sites.  But sometimes I get these Chrome notifications when I am not at my desk or looking at my laptop.  As some of these notifications are useful to me, I would like to be able to access any that I have missed.  Is there a way to view the notification history? $X$,$Y$,$Z$ mutually independent implies $X+Y$ independent of $Z$ Supposing $X$, $Y$ and $Z$ and mutually independent real random variables, how can we prove that $X+Y$ and $Z$ are independent from the definition? If not from the definition, using $\sigma$-algebras?  I know that if $X$ and $Y$ are not independent this doesn't work so I know I have to make use of their independence in my proof but I can't figure out how. And it means that if I write the following, I'm making a mistake, and I can't find it:  $$\mathbb{P}(X+Y \leq k,Z \leq l)=\int_{\mathbb{R}} \mathbb{P}(X=x,Y \leq k-x, Z \leq l) dx=\int_{\mathbb{R}} \mathbb{P}(X=x,Y \leq k-x) \mathbb{P}(Z \leq l) dx = \mathbb{P}(Z \leq l)\int_{\mathbb{R}} \mathbb{P}(X=x,Y \leq k-x)dx= \mathbb{P}(Z \leq l) \mathbb{P}(X+Y \leq k) $$  PS: I have seen the proof here but it much more advanced stuff, kind of a sledgehammer... Modify a shape and have modifications apply to clones Is there any any "Symmetry Modifier" option in illustrator?   Let's say I want to create a head that is totally symmetric. I created one half then mirrored it to get another half. Flipped the other half, aligned them and joined them together with Pathfinder→Unite option.   Now I modified some portion of the right half outline. But how can I get that same modification to be updated on the left option? I thought it would happen automatically. I just picked up a copy of Windows 7 Pro OEM for install on my computer.  Guy at the store said the only real difference between OEM and standard retail box was tech support.  However, the outside of the box has this big warning that says "The software must be installed with an OPK"?  What is the OPK?  Is it really necessary?  The MS site about it seemed to say it was optional.  EDIT:  BTW - I'm just an individual tinkerer, and not a System Builder Company Employee.  I should have made that clear.  I've used sysprep in a professional setting in the past, so I'm somewhat familiar with its concepts. Windows 10 puts my first and last name to lock screen. How to avoid this? After upgrading to Windows 10, I see my LastName and FirstName on the lock screen. Is there a way to change this? On Windows 8.1 there was just my nickname and email address (maybe there were my first name and last name, but not displayed so large as they are now).  I mean the name and surname parameters specified in my Microsoft account.  Another question: I prefer the format FirstName LastName, not vice versa.  Is there any way to change this as well?   Apart from Lock Screen I see it on the Start Menu. What is object serialization? I want to ask about two sentences, and what would be the correct way to form a question:   It's very important that we eat healthy food, ...........?  Which would be the correct question tag: (isn't it) or (don't we)? It's a must that all applicants follow the rules of the competition, ..........?  Which would the correct question tag: (don't they) or (mustn't they)?   Please could you tell me the correct answers, and, more importantly, why those are correct? I am trying to define the probability distribution of $Z$ such as $Z = X_1\cdot X_2$ where $X_1$ and $X_2$ are two independent and identically exponentially distributed variables.  $$P(X_1=x) = \lambda e^{-\lambda x}$$ $$P(X_2=x) = \lambda e^{-\lambda x}$$  I tried something like that….  $$P(Z=x) = P(X_1 = a) \cdot P(X_2 = x/a)$$  Is this first equation correct?  $$P(Z=x) = \lambda e^{-\lambda a} \cdot \lambda e^{-\lambda x/a} = \lambda^2 e^{-\lambda (a+x/a)}$$  I doesn't feel like I found the solution as the dummy variable $a$ remains in the final result. Can you please help me solving this problem? I want to construct a complex power series with the radius of convergence $R=1$ that diverges in:  1) $k$ points on the circle $\{|z|=1\}$.  2) countable number of points on the circle  I have already crafted series that converges on the whole circle and diverges on the whole circle.  Can anybody help with the problem?  Update: I have googled a series $\sum{\frac{z^{kn}}{kn}}$ that is an answer for 1). Though I still need help for the countable case. Matrix reciprocal positive to prove $λ_{max⁡}=n$ Suppose we have $n\times n$ matrix $A$ having only positive elements and satisfying the property $a_{ij}=1/a_{ji}$ (a matrix satisfying this property is called a reciprocal matrix).  If its largest eigenvalue $λ_{max}$ is equal to $n$, then the matrix $A$ satisfies the property (consistency property) $a_{ij}a_{jk}=a_{ik}$ where $i,j,k=1,2,...,n$.    I already found an example of $5\times 5$ reciprocal matrix  to show this condition:  \begin{bmatrix}1&amp;1/2&amp;1&amp;1&amp;1/4\\2&amp;1&amp;2&amp;2&amp;1/2\\1&amp;1/2&amp;1&amp;1&amp;1/4\\1&amp;1/2&amp;1&amp;1&amp;1/4\\4&amp;2&amp;4&amp;4&amp;1\end{bmatrix}  It has simple characteristic equation $λ^5-5λ^4=0$, so the eigenvalues of matrix $A$ are $λ=0$ and $λ=5$ and it's shown that $λ_{max}=n=5$.  Is there anyone can help me to give another positive reciprocal matrix example  that has simple characteristic equation and integer number as its eigenvalues ($4\times 4, 5\times 5$ or $6\times 6$ matrix)? Did merging Black Holes in GW150914 give up entropy and information to the gravitational waves, since they lost 3 solar masses? Since the final Black Hole (BH) had 3 solar masses less of mass than the original binary BH, it seems the 2 BHs lost mass, and with it event surface area, entropy, and information. If that came from inside the BHs it seems that it would be a contradiction of what a BH is --'nothing escapes its event horizon'. Some may say that came from the rotational energy of the pair, but the new BH now seems to have less than the two original ones summed. So, did some of that escape the horizons? I have a problem regarding alignment for my equations.  This dummy program shows the problem:  \documentclass{article} \usepackage{amsmath} \begin{document}  \begin{enumerate}     \item First do this     \begin{align}     c^2 &amp;= a^2 + b^2     \end{align}      \item Then do this      \begin{align}     variable &amp;= c^2     \end{align} \end{enumerate}  \end{document}     I would like the = to be aligned under each other, but still be able to list them inside the enumerate.  Any suggestions? Can a smaller sensor's "crop factor" be used to calculate the exact increase in depth of field? If APS-C and similar crop-sensor digital cameras have a focal length multiplying effect such that a 50mm lens has an apparent focal length closer to the field of view of an 80mm on a full frame camera, and yet at the same time the depth of field for the smaller sensor camera is more like the depth of field a 50mm lens would produce on a full frame camera (using the same aperture), then this would seem to suggest the concept of an "aperture dividing effect."  In other words, a 50mm f/1.8 lens on an APS-C camera would act more like a 80mm f/2.8 (approx. 1.8 * 1.6x) lens in 35mm equivalent — for depth of field, not considering exposure.  Can someone with a better understanding of the physics involved clarify this for me.  I've never seen this concept explicitly mentioned anywhere, so I am a bit suspect of it.