VS Coding Operation Practice ******************

Source: Internet
Author: User

Here are the main exercises of the day: {operator, cast, use of data type, escape character, variable and constant, basic type conversion, etc.}

1) First of all, let's see that the following codes are made up of three major categories

① Custom variables and constants Blue parts

② input part Orange part

③ calculate part of the pink part

④ Output Part Black part

Example://simple Blind Date arithmetic code
string fangzi = "";
string piaozi = "";
string Nengli = "";
string Jieguo = "";
//Input
Console.WriteLine ("Girl: Do you have a house?") (y/n) ");
Fangzi = Console.ReadLine ();
Console.WriteLine ("Girl: Do you have any tickets?") (y/n) ");
Piaozi = Console.ReadLine ();
Console.WriteLine ("Girl: Do you have the ability?") (y/n) ");
Nengli = Console.ReadLine ();
//Calculation
Jieguo = Fangzi = = "Y"? " Let's get married, ":(piaozi==" Y "?" Let's buy a house and get married. ":(nengli==" Y "?" We earn money to buy a house to marry ":" to learn IT skills to earn money to buy a house and then get married! "));

Output
Console.WriteLine (Jieguo);

The second example focuses on

Example two,//time operation code

String Shijian = "";
String AP = "";
int shangwuxiawu = 0;
String Wenhou = "";

//Input
Console.WriteLine ("Please Enter Time:");
Shijian = Console.ReadLine ();
//Calculation
shangwuxiawu = convert.toint32(Shijian); {The conversion of the data at this time is converted from a character to a number}
Wenhou = shangwuxiawu>=0&&shangwuxiawu<6? " It's so cool in the morning! ":(shangwuxiawu>=6&&shangwuxiawu<11?" Good morning! ":(shangwuxiawu>=11&&shangwuxiawu<14?" Good afternoon, ":(shangwuxiawu>=14&&shangwuxiawu<19?" Good afternoon, ":(shangwuxiawu>=19&&shangwuxiawu<24?"                  Good evening ":" Mud sister's ...)));
AP = shangwuxiawu>0&&shangwuxiawu<12? "          AM ":" PM "); {This is a time-based conversion that transforms the 24-hour system into a 12-hour system and adds a suffix ("AM", "PM")}


Output
Console.WriteLine ("{0}{1}\n{2}", Shangwuxiawu,ap,wenhou);

Example three,//recruitment conditions Code
String input age = "";
int conversion age = 0;
string sex = "";
String summary = "";

Input
Console.WriteLine ("Enter your Age:");
Enter age = Console.ReadLine ();
Conversion age = Convert.ToInt32 (input age);
Console.WriteLine ("Enter your Gender:");
Sex = Console.ReadLine ();


Calculation
Summary = Sex = = "female"? Go home and take a break! ":(conversion age >=0&& age <18?" Go home and suck your milk! ":(conversion age >=18&& age <60?" Take the soldiers ":" Go home for retirement! "));


Output
Console.WriteLine (summary);

2016.4.12 Lonely Nightingale Editor

VS Coding Operation Practice ******************

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.