I have heard that fasting causes regeneration of memory cells(B- and T-lymphocytes) thereby improving immunity.Is this true? If yes, how?
Interestingly this effect seems to be true - there is one paper which claims that fasting for three days leads to the depletion of unused (and especially damaged) immune cells to save energy. When food is back at normal rates, the body starts to renew these cells which have been depleted before. This process also seems to enhance the self-renewal process of stem cells which start to replicate and further differentiate.
This works like in the figure below (from the paper below):
Although this renews a part of the immune cells, I wouldn't say that this improves the immune system. I think that here mostly naive cells (which haven't) come in contact with an antigen are shut off. If you deplete memory cells (which had this contact) this would be counterproductive, since these cells are important for a fast immune response.
There is as well an article in Science Daily, which summarizes the original paper. It can be found here.