Variables

 private void button1_Click(object sender, RoutedEventArgs e)    

     {            // int x, y;     

                  //x = 7;            

                 //y = x + 3;            

          //textBlock1.Text = y.ToString();            

      //c#是区分大小写的语言            

               //string myfirstname;              

       //myfirstname = "olive";            

     //textBlock1.Text = myfirstname;

           // string myfirstname = "olive";            

     //textBlock1.Text = myfirstname;

           /* int x = 7;            

    string y = "olive";           

       string myfirstry = x+y;            

//int mysecondtry = x + y;             

textBlock1.Text=myfirstry;            

//textBlock1.Text = mysecondtry;            

 */            

 //c#中能够把int隐形的转换为string,即为myfirsttry的情况            

//但是不能把string隐形的int,即为mysecondtry,要想转换必须人工强制转换。

             int x=7;             

            string y="5";             

         int mythirdtry = x + int.Parse(y);/*把string y强制转换为int型的*/             

        textBlock1.Text = mythirdtry.ToString();             ;

                                      

        }    

posted @ 2012-03-05 19:19  zhangmengjie  Views(126)  Comments(0)    收藏  举报