岂几吧 关注:7贴子:1,085
...


IP属地:福建1楼2015-11-26 16:21回复
    输入..length = Convert.ToDouble(Console.ReadLine());
    是直接cw 简单快捷


    IP属地:福建2楼2015-11-26 16:23
    回复
      用out传值方法。
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      namespace ConsoleApplication1
      {
      class Program
      {
      static void Main(string[] args)
      {
      out_test ot = new out_test();
      int a=10;
      ot.getvaule(out a);
      Console.WriteLine(a);
      Console.ReadKey();
      }
      }
      class out_test
      {
      public void getvaule(out int x)
      {
      x = 5;
      }
      }
      }


      IP属地:福建3楼2015-11-27 09:07
      回复
        接上:键入再输出
        public void getValues(out int x, out int y )
        {
        Console.WriteLine("请输入第一个值: ");
        x = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("请输入第二个值: ");
        y = Convert.ToInt32(Console.ReadLine());
        }


        IP属地:福建4楼2015-11-27 09:10
        回复
          接上:
          写成
          try
          {
          y = Convert.ToChar(Console.ReadLine());
          }
          catch (Exception ex)
          {
          Console.WriteLine(ex.Message);
          }
          防止各种谜之弹窗。。


          IP属地:福建5楼2015-11-27 09:55
          回复
            Response.Write("<script>alert('加载') </script>"); 网页弹窗


            IP属地:福建6楼2015-11-29 00:09
            收起回复
              关于alert
              无刷新弹出警告:
              ScriptManager.RegisterStartupScript(this.Page, this.GetType(),"onekey", "alert('弹出')", true);
              而以下方法,会刷新弹出,比较难看
              Response.Write("<script>alert('弹出')</script>");
              ClientScript.RegisterStartupScript(this.Page, this.GetType(),"onekey", "alert('弹出')", true);


              IP属地:福建7楼2015-11-30 11:24
              回复
                string username = string.Empty; 创建新的字符串
                如果string username;的话
                用不了 username.Length 报未赋初值的错误


                IP属地:福建8楼2015-12-01 10:13
                回复
                  C#更新数据
                  前面open了myconnection
                  sql = "update[lk_logon].[dbo].[logon] set password='" + new_pwd + "'where [uid]='" + uid + "'";
                  SqlCommand comm2 = new SqlCommand(sql, myconnection);
                  Response.Write(sql);
                  comm2.CommandText =sql;
                  comm2.ExecuteNonQuery();


                  IP属地:福建9楼2015-12-01 13:17
                  回复
                    using System;
                    public class HelloWorld
                    {
                    public HelloWorld()
                    {
                    Console.WriteLine("HELLO WORLD");
                    }
                    public static void Main()
                    {
                    HelloWorld hw = new HelloWorld();
                    Console.Read();
                    }
                    }
                    加了一个void ,却从构造函数变成了类的一种方法(面向对象)了
                    using System;
                    public class HelloWorld
                    {
                    public void helloWorld()
                    {
                    Console.WriteLine("HELLO WORLD");
                    }
                    public static void Main()
                    {
                    HelloWorld hw = new HelloWorld();
                    hw.HelloWorld();
                    }
                    }


                    IP属地:福建10楼2015-12-15 10:48
                    回复
                      1.ctrl+g 快速转到第几行
                      2.字符串@"path"放路径 可以不用加很多反斜杠
                      3.@可以多行字符串
                      4.显式转换 int转换成char的时候 int范围比char大 就要显式转换 反过来 隐士转换就可以
                      5.parse是啥?


                      IP属地:福建11楼2015-12-17 08:33
                      回复
                        练习而已:
                        using System;
                        using System.Collections.Generic;
                        using System.Linq;
                        using System.Text;
                        namespace ConsoleApplication1
                        {
                        class Program
                        {
                        static void Main(string[] args)
                        {
                        int num;
                        string key;
                        while(true)
                        {
                        key = Console.ReadLine().ToString();
                        if(key=="q")
                        {
                        Console.WriteLine("退出");
                        break;
                        }
                        else
                        {
                        try
                        {
                        num = int.Parse(key);
                        Console.WriteLine(num*2);
                        }
                        catch (Exception)
                        {
                        Console.WriteLine("输入错误");
                        }
                        }
                        }
                        }
                        }
                        }


                        IP属地:福建12楼2015-12-18 14:48
                        回复
                          漏了一句 引发死循环



                          IP属地:福建13楼2015-12-18 15:03
                          回复

                            这样枚举应该看得懂了吧


                            IP属地:福建14楼2015-12-18 15:29
                            回复
                              这个我写的

                              这个好些


                              IP属地:福建16楼2015-12-18 17:21
                              回复