I was working on a c# program today and ended up having to chase a bug for quite some time.   I was trying to make a copy of an object change a few fields and send it on as well as the original  for example  Function(Object A) {     Object B = new Object();     Object B = A;      B.foo = "bar";      Send(A);      Send(B); }   My program started treating A and B as the same object meaning that any changes to A would also change B and vise versa.  I know that the Object A and B are both referencing the same memory.  Is there a short hand way to ensure the line Object B = A references new memory thus creating different objects. Or is the only way to create a copy constructor in my Object and create B with Object B = new Object(A)  eg:   Object(Object a){    foo = a.foo;    ... }   Basically i just what to know more about how C# handles object references and memory allocations. Big subject i know.
I want to do something like:  MyObject myObj = GetMyObj(); // Create and fill a new object MyObject newObj = myObj.Clone();   And then make changes to the new object that are not reflected in the original object.  I don't often need this functionality, so when it's been necessary, I've resorted to creating a new object and then copying each property individually, but it always leaves me with the feeling that there is a better or more elegant way of handling the situation.  How can I clone or deep copy an object so that the cloned object can be modified without any changes being reflected in the original object?
Why can a discontinuous function not be differentiable? I don't really understand why a discontinuous function cannot be differentiable.  In Stewart's Calculus, the definition of a function $f$ being differentiable at $a$ is that $f'(a)$ exists. Earlier it gives the definition of the derivative as $f'(x)=\lim_{h\to0}\frac{f(x+h)-f(x)}{h}$. It also has a theorem that if $f$ is differentiable at $a$, then $f$ is continuous at $a$. There is also a definition that a functions $f$ is continuous at a number $a$ if $\lim_{x\to a}f(x)=f(a)$.  Take for example the very simple function:  $$ f(x)=\begin{cases} x+1 &amp; x\geq0, \\ x &amp; x&lt;0.  \end{cases} $$  It is discontinuous at $x=0$ (the limit $\lim_{x\to 0}f(x)$ does not exist and so does not equal $f(0)$), but if I find the derivative using the limit above, I get the left and right limits to equal $1$. So therefore, the derivative exists.  According to the book, the function shouldn't be differentiable at $x=0$ as it has a discontinuity (continuity is a necessary condition of differentiability). What am I doing/understanding wrong? I'm kind of curious what kinds of criteria other people go through when selecting the correct answer to their questions.  Here's what I consider when selecting the answer to my question:   Is the answer objective?  It's easy to pick out biased answers.  Usually they involve a statement along the lines of "x sucks, you should ALWAYS use y." Do other members seem to support the answer?  Has it gotten a significant number of +1 posts or has it been voted up a number of times? Is the answer the most thorough?  Does it have an example?   With that said, there are a couple of BAD reasons to choose an answer in my opinion:   The answer is what you want to hear.  My biggest pet peeve is when somebody asks what ostensibly appears to be a valid question, but is really just a thinly veiled attempt to get someone to agree with them.  Thus, the question usually ends up showing a certain bias.  And guess which answer gets selected?  The one that confirms that bias. Nobody posted a better answer.  If you don't see a good enough answer, don't select one.   I'm sure there are a few things I'm leaving out, plus some of what I've said may be arguable.  What is everyone else's take on this? I'm using TeXLive 2014. Here's a MWE:  \documentclass{article} \usepackage{tkz-fct}         % Must appear before {thmtools}  \usepackage{thmtools} \declaretheorem{theorem}  \begin{document}   \begin{tikzpicture}     \tkzInit  % No need to even plot anything!   \end{tikzpicture}    \begin{theorem}[A Silly Theorem]     Let $a = 1$. Then $a &gt; 0$.   \end{theorem} \end{document}   The error message is:  ! Extra \endcsname. \kv@processor@default ...fincsname\@xa \endcsname                                                   \csname iftrue\endcsname \... l.12   \begin{theorem}[A Silly Theorem]   If the optional theorem name is removed, all is well. Adding \protect{} doesn't help.  Any idea how to remove this conflict?  Thanks! Help with multirow table I am trying to wrap text in the multirow column (1st one) and only have the vertical lines inside the table if that makes sense.   Can anyone help me? `  \begin{table*}[!htbp] \centering \renewcommand{\arraystretch}{1.4} \begin{tabular}{|c| p{2cm}|c|c|c|c|} \cline{3-6} &amp;&amp;\multicolumn{2}{c|}{\textbf{Gravité du Dommage G1}} &amp; \multicolumn{2}{c|}{\textbf{Gravité du Dommage G2}}\\  \cline{3-6} &amp;&amp;\textbf{Fréquence F1} &amp; \textbf{Fréquence F2} &amp; \textbf{Fréquence F1} &amp; \textbf{Fréquence F2}\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O1}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O2}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \multirow{ 2}{*}{\textbf{Probabilité Occurence O3}}&amp;\textbf{Possibilité Evitement P1}&amp;&amp;&amp;&amp;\\ \cline{2-6} &amp;\textbf{Possibilité Evitement P2}&amp;&amp;&amp;&amp;\\ \hline \end{tabular} \end{table*} How would you go about proving that $$\gcd \left(\frac{a}{\gcd (a,b)},\frac{b}{\gcd (a,b)}\right)=1$$  for any two integers $a$ and $b$?  Intuitively it is true because when you divide $a$ and $b$ by $\gcd(a,b)$ you cancel out any common factors between them resulting in them becoming coprime. However, how would you prove this rigorously and mathematically? Science fiction short story: beam transporting people into the distant future Problem from iOS 10.1.1 to 10.2.1.  I have no photos at all on my iPhone yet in settings it says my photo library is taking up ~200MB of space. The number of space being taken up keeps changing constantly(in the settings app on my phone). In iTunes, the storage bar at the bottom does(when in the sync menu) not show photos.           What is taking up this storage, and how can I reduce it?  Troubleshooting:   I disabled iCloud photo library and iCloud photo stream, still showing the same thing. Tried doing what @User9125 said, didn't work. I had set the date all the way back when I first got my phone, nothing showed up. Rebooting I had hundreds of photos in Whatsapp, I deleted them but I didn't get the storage back. It didn't even make a dent in the amount of storage being used by Photos so I don't think a third-party app could be taking up this storage. I don't think a system app is taking this space either, because I cleared the pictures in mail and messages. I tried using (through sideloading) in Secure Mode and Fast Mode, but it did not clear up the photos. Where are Steam games installed? I want to buy a new notebook in the near future to play games on it. I'm looking forward for the new Steam for Linux client. My question is that where does the Steam install the games, on the home partition, or in the usr folder, or somewhere else? I do not use pre-release (i.e. beta) versions of either Steam or Ubuntu. Seating of $n$ people with tickets into $n+k$ chairs with 1st person taking a random seat "$n$ music lovers have reserved seats in a theater containing a total of $n+k$ seats ($k$ seats are unassigned). The first person who enters the theater, however, lost his seat assignment and chooses a seat at random. Subsequently, people enter the theater one at a time and sit in their assigned seat unless it is already occupied. If it is, they choose a seat at random from the remaining empty seats. What is the probability that person $n$, the last person to enter the theater, finds their seat already occupied?"  I could do this problem for small specific values of $n$ and $k$ but as they grow the expressions seem to get really messy really quick with no discernible pattern. How would one solve this problem? Simplest way to send one-line mail out via command line using gmail? Using Raspbian and Ubunntu 16.04 LTS so need a generic Linux solution.  Requirement is simple:  I need a way to send one-line email messages from the command line.  I have set up a gmail account just for this particular Rpi3, with the address of rpi3abc@gmail.com - with no 2FA  So now I need to be able to send one-line mail messages from anywhere (including cron) without user intervention.    I also would like it to be able to send text files; basically, anything from stdin. Model Selection: Logistic Regression Finding the index of an item in a list Deriving input based on other parameters in Python script tool? I have a folder and it contains two feature classes, e.g., a.shp and b.shp. The script tool created has two parameters. The first one is the model location, and the second one needs a feature class (a.shp), as shown in the below picture.  What I really want is every time when I set up the model location for the first input, the second input will automatically find the a.shp as the input rather than the user needs to choose a.shp from that folder. I noticed that the dependency is probably what I really need, but there is no code example. Any suggestions?   I am using ArcGIS 10.3.1 Advanced License. why is the set of all binary sequences not countable? Why don't self-closing script elements work? What is the reason browsers do not correctly recognize:  &lt;script src="foobar.js" /&gt; &lt;!-- self-closing script element --&gt;   Only this is recognized:  &lt;script src="foobar.js"&gt;&lt;/script&gt;   Does this break the concept of XHTML support?  Note: This statement is correct at least for all IE (6-8 beta 2). In .NET, the  is used in a lot of places throughout the .NET base class libraries. Implementing it properly is especially important to find items quickly in a collection or when determining equality.  Is there a standard algorithm or best practice on how to implement GetHashCode for my custom classes so I don't degrade performance? How can I get admin access to a Mac without knowing the current password? My Father died last year and I inherited his Mac Mini. My wife has retired and we are trying to set up the mini for her use but the changes we want to make require admin access and we do not have the information my father used to set up the machine.  Is it possible to reset the admin information without having the old information? If so, how would I go about it?   I am not a Mac user usually so any guidance will have to be pretty simple! Tweak showlabels/showkeys - wrap the label In his lectures on String Theory (), Tong gives a proof of the Weyl anomaly, using equation $(4.36)$. It seems wrong to me.  Here he uses the OPE between the stress-energy tensors $T_{zz}T_{ww}$  obtained when trace vanishes, i.e. $T_{z \bar{z}} = 0$: this implies that they are holomorphic functions $T_{zz} = T_{zz}(z)$. But in this proof he starts from the fact that $T_{z \bar{z}} \neq 0$ (we want to proof this thing after all) and so $T_{zz}$ is not a holomorphic function anymore! In the OPE $(4.36)$ I should have also terms with $(\bar{z}- \bar{w})$.  I can't also understand why he uses in the rest of the proof only the singular term $(z-w)^{-4}$, neglecting the other ones $(z-w)^{-2}$, $(z-w)^{-1}$.  (The same proof is given in these lectures  on conformal field theory, equation $(6.9)$).  I'll be really thankful if someone could explain me this proof :) I'm trying to identify fantasy book series I encountered some time ago. Here are things I remember:   it was a fantasy setting but with some s-f elements; with many worlds and possibility to travel between them; resembling  setting a little, the two main races were non-human and probably hostile to each other,  a labyrinth (?), which somehow played an important role in the plot, a protagonist was some kind of emissary and was sent on a mission to another worlds  time period: 80s - 90s    Does anyone know what it is the name of the series?