I have the following code:  for (int i = 0; i &lt; 10000; i++ ) {     list.Add(new Point(i, 3)); }  for (int i = 0; i &lt; 10000; i++) {     list[i].X = 100; }  Point point = new Point(0, 1); point.X = 1; point.Y = 10;   When I try to change X or Y property of a newly created Point structure there is no problem:  Point point = new Point(0, 1); point.X = 1; point.Y = 10;   But when I'm trying to do the same in a loop  for (int i = 0; i &lt; 10000; i++) {     list[i].X = 100; }   The compiler is telling me     Cannot modify the return value of   System.Collections.Generic.List&lt;System.Windows.Point&gt;.this[int]   because it is not a variable   Can anybody please explain me this.
I have a list of structs and I want to change one element. For example :  MyList.Add(new MyStruct("john"); MyList.Add(new MyStruct("peter");   Now I want to change one element:  MyList[1].Name = "bob"   However, whenever I try and do this I get the following error:     Cannot modify the return value of   System.Collections.Generic.List.this[int]‘ because it is not   a variable   If I use a list of classes, the problem doesn't occur.  I guess the answer has to do with structs being a value type.  So, if I have a list of structs should I treat them as read-only? If I need to change elements in a list then I should use classes and not structs?
Possible Duplicate:          I'm looking for a good book on commutative algebra covering most of (but not limited to) :   Basic Galois theory and Module algebra Primary decomposition of ideals Zariski topology Nullstellensatz, Hauptidealsatz Noether's normalization Ring extensions "Going up" and "Going down"   The emphasis is on the approach, as I would like a book giving a good geometric intuition of ring theory that I could use as a solid basis to start learning algebraic geometry.  All in all, do you remember a book that gave you a deeper geometric insight of commutative algebra ? Exact probability of random graph being connected The problem: I'm trying to find the probability of a random undirected graph being connected. I'm using the model $G(n,p)$, where there are at most $n(n-1) \over 2$ edges (no self-loops or duplicate edges) and each edge has a probability $p$ of existing. I found a simple formula online  where $f(n)$ is the probability of $G(n,p)$ being connected. But apparently it's too trivial for the writer to explain the formula (it was just stated briefly).  The desired formula: $f(n) = 1-\sum\limits_{i=1}^{n-1}f(i){n-1 \choose i-1}(1-p)^{i(n-i)}$  My method is: Consider any vertex $v$. Then there's a probability ${n-1 \choose i}p^i(1-p)^{n-1-i}$ that it will have $i$ neighbours. After connecting $v$ to these $i$ neighbours, we contract them ($v$ and its neighbours) into a single connected component, so we are left with the problem of $n-i$ vertices (the connected component plus $n-i-1$ other "normal" vertices.   Except that now the probability of the vertex representing connected component being connected to any other vertex is $1-(1-p)^i$. So I introduced another parameter $s$ into the formula, giving us:  $g(n,s)=\sum\limits_{i=1}^{n-1}g(n-i,i){n-1 \choose i}q^i(1-q)^{n-1-i}$,  where $q=1-(1-p)^s$. Then $f(n)=g(n,1)$. But this is nowhere as simple as the mentioned formula, as it has an additional parameter...  Can someone explain how the formula $f(n)$ is obtained? Thanks! systemd-resolve high cpu usage after update to 17.04 Simple logic problem: Finding largest and smallest number among 3 numbers According to the microtype manual, Kerning, Spacing and Tracking are not enabled by default in pdftex (>= 1.4). What are the reasons for this? Who did that to the priest's dog? In John Michael McDonagh's wonderful philosophical black comedy , a good priest receives a death threat during a confessional giving him a week to sort out his affairs.   During the course of the week there are a lot of encounters between the priest and his parishioners, many acting as red herrings to distract the audience form the identity of the potential killer. Several threatening acts also take place: the church is burned and the priest's dog is killed.   But in the final encounter between the priest and the mystery antagonist (I'm not saying who to avoid spoilers) the antagonist admits burning the church but claims not to have killed the priest's dog.  Are they lying? Or is there a good reason that someone else might have killed the dog? What, if anything should one do if a user's "about me" profile section contains extremely inflammatory terms (racist, etc.) I don't think anyone wants to be the thought police, and I'm particularly wary of censorship on a part of the site that is a user's personal self-statement, and is a little off the beaten path.  On the other hand, I'm also concerned that we may not want a site where clicking on a user to see their other posts would expose folks to racist or other bigoted terms that almost everyone would agree are inappropriate for civil discourse.    Don't forget the "be nice" rule".  Note that I don't want a "flag user" rule, which I know has been beaten to death already, and further think that swears and semi-inflammatory opinions, etc. should generally just be ignored - I'm only asking about terms that provoke serious emotions around racial, religious, ethnic, or sexual orientation issues.  What, if anything, is the appropriate response in such cases? Evaluate the following limit of finite sum How often should I remove the charger from my rMBP? I want my battery to remain healthy. I used to charge it full then remove the charger after it's done, then put it back on when it goes down to 10% .. However this is becoming hectic and I was wondering if I can keep it plugged in the whole day and probably remove just an hour or so before going to sleep.  What is the best way to charge and discharge my Retina Macbook Pro while keeping the battery healthy ? Programmatically Create X509 Certificate using OpenSSL I have a C/C++ application and I need to create a X509 pem certificate containing both a public and private key.  The certificate can be self signed, or unsigned, doesn't matter.  I want to do this inside an app, not from command line.  What OpenSSL functions will do this for me?  Any sample code is a bonus! db_update Query Issue I am using ubercart guest checkout module. I am able to submit  the order as guest etc works fine.   After Reviewing the order and submitting it throws me this error   Recoverable fatal error: Argument 2 passed to db_query() must be an array, string given, called in /var/www/html/dev.demo.net/sites/all/modules/ubercart_guest_checkout/uc_guest_checkout.module on line 263 and defined in db_query() (line 2342 of /var/www/html/dev.demo.net/includes/database/database.inc).   This is the query which is causing that issue    db_query('UPDATE {users} SET name = "%s", mail = "%s" WHERE uid = %d', $name, $mail, $account-&gt;uid);   I tried to change this query like this  db_update('users') -&gt;fields(array(     'name' =&gt; $name,     'mail' =&gt; $mail )) -&gt;condition('uid',$account-&gt;uid,'=')        -&gt;execute();   still no luck, it throws me same above specified error.    How can i resolve the query of above one in order to avoid the error. Any suggestions w.r.t query will be nice.Thanks in advance. How to resize my dual-boot partitions I have a dual-boot laptop with both Windows 10 and Ubuntu 16.04.  Currently, the Windows side has too much disk space, and I want to resize things so that the Ubuntu side has more.  Firstly, I went into the Windows disk management and shrunk the Windows partition by 20GB. I then wanted to expand the Ubuntu partition, but it seemed like this option was greyed out.  Can I expand the Linux partition from Windows or do I need to be in Ubuntu or do I need to create a boot disk and do it that way?  Or do I need third party software?  Any help gratefully received. How to output string completions to stdout? When logging in C#, how can I learn the name of the method that called the current method? I know all about System.Reflection.MethodBase.GetCurrentMethod(), but I want to go one step beneath this in the stack trace. I've considered parsing the stack trace, but I am hoping to find a cleaner more explicit way, something like Assembly.GetCallingAssembly() but for methods. Behaviour of return statement in catch and finally How to use Font as a variable? Do you have advantage when multiple sources give advantage and only one gives disadvantage? As I understand it:   if you have Advantage from two different sources, you simply have Advantage (no stacking) if you have advantage from one source, and disadvantage from one source, they cancel out.     So what if you have advantage from two or more sources, and disadvantage from one source?  My assumption is that you simply have advantage, or put another way, you have Advantage on a roll when the # of Advantages > # of Disadvantages (and vice versa).  Is that correct? Going through a text file line by line in C Voting to Close after Accidentally Voting to Leave Open When reviewing on SO, I accidentally pushed the "Leave Open" button on a post that clearly should've been closed. I pushed the back button and saw that in the review panel my vote to keep open had been locked and it said:     PhpMyCoder voted to leave open 1 minute ago   So I clicked on the question heading to go to its page and I clicked the close link on the question page and voted to close for the relevant reason. However, when I returned to the review page (and did a hard refresh) it still said:     PhpMyCoder voted to leave open 2 minutes ago   Is it possible to vote to leave open and vote to close at the same time? I assume not. In which case, I'd say this is a bug because it should've updated to say:     OtherUser and PhpMyCoder voted to close 2 minutes ago What does a type followed by _t (underscore-t) represent? This seems like a simple question, but I can't find it with the Stack Overflow search or Google. What does a type followed by a _t mean? Such as  int_t anInt;   I see it a lot in C code meant to deal closely with hardware—I can't help but think that they're related.