Internet in the trains
All long distance trains are equipped with 3G/4G signal amplifiers. If you have a phone with internet access, you can use this improved signal. Most trains do not have Wifi.
You can use your smartphone to pick up the 3G/4G signal and configure the phone as a Wifi hotspot. That allows Wifi enabled equipment such as a laptop or a tablet to access the internet. Buy an appropriate SIM card or Wifi hotspot to save money.
Free internet at the train stations
About 80 rail stations, including the ones in all larger towns, offer free Wifi that can be accessed for an hour. You can connect to the Wifi network and start your browser. You need a smart phone that can receive a text message for the one time registration. Two hours after the hour has ended one can use it for another hour.
Internet in other places
Nearly all hotels offer free or paid Wifi. Mobile internet is available in nearly all inhabited areas. Don't expect internet to be available in remote areas. If internet connectivity is important to you, be sure to arrange for a Swiss SIM card or mobile hotspot.