Each cell of a human body contains 46 chromosomes. If so then each cell of a kidney should have a pair of sex chromosomes. How is it possible that a kidney of a female donor will work on male kidney patient?
The Chromosomes are not the main Factor in this. The immune system (and antibodies) is, this is a bit different. For example females have a higher HLA antigens and therefore rely on more immunsuppressive therapy.
This Therapy is the thing that makes a transplantation possible, nearly all Organs are incompatible to the body, that means that you always have to give medication to stop the body from attacking the new organ. How much is needed is done via HLA matching (see UC Davis (n.d.)), which is quite extensive as a topic, you can read the lkink if you want to dig deeper. In short, depending on the HLA classification you might have a risk to not accept your new organ and therefore your medication will be tailored to the compatibility.
Also difference between Male/Female in general is comparably small,there are some studies and you can read Puoti et al (2016) for some differences in survival rates etc.
Puoti, F., Ricci, A., Nanni-Costa, A., Ricciardi, W., Malorni, W., & Ortona, E. (2016). Organ transplantation and gender differences: a paradigmatic example of intertwining between biological and sociocultural determinants. Biology of sex differences, 7(1), 35. doi: 10.1186/s13293-016-0088-4 pmcid: 4964018
UC Davis (n.d.) HLA Typing/Matching [Online]
Retrieved from: https://health.ucdavis.edu/transplant/learnabout/learn_hla_type_match.html
@NilsPawlik has addressed the issue of a donor/recipient gender mismatch (it's not the most important factor, but it is something to consider). I thought I'd clarify the point about donor/recipient compatibility.
What makes an organ compatible?
There are a number different things that make a donor organ work more or less well for a recipient, but each kind of organ has its own challenges. For example, where size matching is not an issue for liver transplants, it is important for heart transplants, and may be a little important for kidney transplants (Schwartz Principles of Surgery, Ch. 11)*. For all solid organ transplants, though, the major driver of organ and tissue compatibility is found in 6 genes on the short arm of chromosome 6.
Antigens distinguish self from non-self
All jawed vertebrates have an adaptive immune system and are able to tell the difference between invaders (non-self) and things that are a part of their own body (self). This system works by examining patterns in biological molecules (proteins, sugars, lipids). Those patterns are called antigens. When you transplant an organ from a donor to a recipient, the recipient's immune system will look at the antigens, or patterns, on the cells of the donor organ, and make a decision about whether those cells are part of their body or part of an invader.
Identifying and responding to antigens involves the entire immune system
The way the immune system examines and responds to those antigens involves a whole series of important and complicated interactions between many different soluble proteins, receptors, and cells, including antibodies, T-cell receptors, cytokines, macrophages, and more, but the key to predicting which organs will work well is looking at the antigens themselves.
HLAs determine whether a recipient will recognize a donor organ as self or non-self
The most important antigens for figuring out whether a human donor organ will be compatible with a human recipient are called Human Leukocyte Antigens (HLA), because they are molecular patterns (antigens) initially discovered on human white blood cells (leukocytes). These antigens are very important functional proteins that play a particular role in the way the immune system works, but for our purposes you can just think of them as being little markers on each cell saying either "I'm one of you!", or "I'm not one of you!".
These markers (human leukocyte antigens) are encoded in the genome. Their genes are found on the short arm of chromosome 6. These genes are part of a group of genes called the Major Histocompatibility Complex (or MHC), because they are a major part of determining whether a donor tissue (histo) will be compatible with a recipient's immune system.
What kind of a match do you need?
There are many many many different types of MHC alleles. Because HLAs strongly influence our ability to respond to infection, this variability is a good thing overall, but it makes transplant immunology complicated. Because there are so many different MHC alleles, finding a match can be difficult. Organs are in short supply, though, so rather than waiting for an exact match, the goal is often to find a match that is good enough.
In addition to the linked articles and the surgical considerations discussed in Schwartz, much of the relevant immunology here is discussed in good detail in the Transplant Immunology subsection of Chapter 11. I also recommend Lauren Sompayrac's little book, How the Immune System Works for either an introduction or review.
*Even the mechanisms of immune rejection vary from organ type to organ type. Liver transplants, for example, are not as susceptible to the kind of rejection that is caused by pre-formed antibodies. They are more susceptible to the kind caused by T-cells (again, Schwartz Ch. 11, unless you want to see how this is even more complicated)