Food plays such an important role in Chinese culture that when people meet, they often greet each other with the words, "Have you eaten?" (Chi le ma?). For the visitor to China, food will (or should) be one of the highlights of your trip. If you're traveling on a group tour, you'll likely be fed fare that is fairly ordinary and generic, and above all inexpensive. Try to sneak out for an independent Chinese meal if possible. Mealtimes are practically sacred, and you'll find, especially if you are on an organized tour, that visits and events are often scheduled around meals, which are usually taken early (11:30am-noon for lunch and 5:30-6pm for dinner). In a city such as Shanghai, few businesses or tourist attractions close for the lunch hour, though this is more common in smaller Chinese towns.
Following Daoist principles, Chinese cooking aims for a balance of flavors, textures, and ingredients. Certain foods are thought to have yang (warming) or yin (cooling) properties, and the presence of one should ideally be offset by the presence of its opposite. Seldom is one ingredient used exclusively, and meals should reflect that harmonious blend of meat and vegetables, spicy and bland, and so forth. China has a staggering variety of regional cuisine that reflects the different ingredients available in a particular environment, and also emphasizes different cooking methods, and you are encouraged to try as many of these as possible while you are in the country. Chances are that little of it will taste like the food from the neighborhood Chinese restaurant back home; if anything, it'll taste better.
While you can sample most of the diverse Chinese cuisines in Shanghai (though admittedly, few ethnic Chinese cuisines make it here entirely intact, as the local preference for sweet invariably finds its way onto most menus), the emphasis here is on Shanghai's traditional cuisine, also known locally as benbang cai. Considered a branch of the Huaiyang style of cooking, Shanghai cooking favors sugar, soy sauce, and oil, and seafood is featured prominently. While it is true, as some critics allege, that traditional Shanghai cooking does tend towards the oily and the over-sweet, many typical Shanghai dishes are simply delicious and deserve to be tried, as it's likely you won't find much like it back home.
You can find the following typical Shanghai dishes in any local restaurant serving benbang cai: cold appetizers such as xunyu (smoked fish), kaofu (braised gluten), zui ji (drunken chicken marinated in Shaoxing wine), and pidan doufu (tofu with "thousand-year-old" eggs); snacks like xiaolong bao (steamed pork dumplings with gelatinous broth), shengjian bao (pork-stuffed fried bread dumplings), and jiucai hezi (leek pie); traditional dishes such as chao niangao (fried rice cakes), Shanghai cu chaomian (Shanghai fried thick noodles), shizi tou (braised "lion's head" meatballs), tipang (braised pig trotters), meicai kourou (braised pork with preserved vegetables), youmen sun (braised fresh winter shoots), jiaobai (wild rice stems), shuijing xiaren (crystal prawns), dazha xie (hairy crab), xuecai maodou baiye (bean-curd sheets with soy beans and salted winter greens), and the soup yanduxian (pork-based broth with ham, bamboo shoots, and bean curd skin). Desserts include babaofan (eight-treasure glutinous rice) and dousha subing (red bean paste in flaky pastry).
Regional differences notwithstanding, Chinese food is usually eaten family-style, with a number of dishes to be shared by all. If you find yourself dining solo, you can ask for xiao pan (small portions), usually about 70% of the full dish and the full cost, though not all restaurants will accommodate this request. Dishes can arrive in random order, though most meals usually begin with cold appetizers (liang cai), then move on to seafood, meat, and vegetable main dishes. Except in Cantonese cuisine when it's taken as one of the first courses, soup is usually served last. Plain rice is typically eaten as an accompaniment in your average proletarian setting, but is seldom voluntarily offered in finer dining, where the emphasis is supposed to be on the subtle flavors of each dish and ingredient, and rice is considered a mere filler. (You can always request rice if it's not automatically offered.) Outside of the more sophisticated restaurants, the food in many places throughout the country can be a bit more greasy than foreigners are used to; if this is a cause for concern, you can specify beforehand shao you ("less oil"), though don't expect this request always to be honored.
In your average Chinese restaurant, dessert, if it exists, usually consists of a few orange wedges and not much else, though Shanghai and Cantonese cuisines feature a slightly wider choice of sweets such as red bean pastries (dousha subing), and sesame seed paste (zhima hu). Tea is usually served free, though if you're asked what kind of tea you want, you'll probably be charged for it. A vintage like longjing tea (from the Hangzhou) is considerably more expensive than something like your average chrysanthemum (juhua cha) or jasmine tea (molihua cha). Napkins and chopsticks should be free, though if you're given a prewrapped package of tissues, you'll likely be charged for opening it, and possibly for the peanuts as well. In general, there is no tipping, though a few restaurants outside the major hotels may add on a service charge, which usually guarantees you won't get much in the way of service.