An outbreak of gastroenteritis has landed more than 3500 people in NSW hospitals over the past fortnight.

NSW Health says primary school-aged children and people in aged care facilities, hospitals and child care have been struck down by the epidemic.

NSW Health Director of Health Protection, Dr Jeremy McAnulty, says viral gastroenteritis is highly infectious and warns those afflicted to stay away from vulnerable people in hospitals and aged care facilities.

"These outbreaks are mostly caused by infection with a virus, most often norovirus or rotavirus, and spread easily from person to person," Dr McAnulty said in a statement.

"It is vital that if you or your family contract gastroenteritis that you stay home from work or keep a child home from school if they are sick."

People with the virus should avoid preparing food for others until at least 48 hours after recovery, he said.

Good hygiene is also essential to avoid contracting the virus by washing hands thoroughly with soap and running water for at least 10 seconds before handling and eating food, and after visiting the bathroom.

Symptoms include nausea and diarrhoea.

People who are concerned should visit their local GP.