你弄错类型了吧,''是用来括起char类型的字符,只能写一位。
 int a = Console.ReadLine();  也有问题,要先转换。

解决方案 »

  1.   

    哦,帖子中我写错了,实际用的是下面的,还是有问题,出现if条件中数字太多的错误提示
                 Console.Write("Please enter 4 digital number: "); 
                    int a = convert.int32(Console.ReadLine());                 if (a=='1234') //这里会提示太多数字了,郁闷,如果要做,请问如何写,请指教,谢谢! 
                    { 
                        Console.WriteLine("Please enter your password: "); 
                    }
      

  2.   

    恩,类型转换没搞懂呀,建议楼主再去看看书,把类型转换好好看看吧~~~Console.Write("Please enter 4 digital number: "); 
    int a = int.Parse(Console.ReadLine()); //要把string转换为int
    if (a==1234)  //a是int,不是char

        Console.WriteLine("Please enter your password: "); 
    }
      

  3.   

    class Class1
    {
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    //
    // TODO: 在此处添加代码以启动应用程序
    //
    Console.Write("Please enter 4 digital number: "); 
    int a;
    try
    {
     a = Convert.ToInt32(Console.ReadLine()); 
    }
    catch(Exception e)
    {
    Console.WriteLine("Exception in Main: " + e.Message);
    }
    finally
    {
    a = Convert.ToInt32(Console.ReadLine()); 
    if (a.ToString().Length > 4 )
    {
    Console.WriteLine("########## "); 
    }
    else
    {
     Console.WriteLine("Please enter your password: "); 
     Console.Read();
    }
    }
    }
    }
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace Questen
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.Write("Please input 4 number:");
                
                if (Convert.ToInt32(Console.ReadLine()) == 1234)
                {
                    Console.WriteLine("Input you password!");
                    Console.ReadKey();
                }
            }
        }
    }