解决方案 »

  1.   

    string strT = Convert.ToString(变量);
      

  2.   

    using System;class Sample 
    {
        public static void Main() 
        {
        string nl = Environment.NewLine;
        string str = "{0}Return the Int64 equivalent of the following base types:{0}";
        bool    xBool = false;
        short   xShort = 1;
        int     xInt   = 2;
        long    xLong  = 3;
        float   xSingle = 4.0f;
        double  xDouble = 5.0;
        decimal xDecimal = 6.0m;
        string  xString = "7";
        char    xChar   = '8'; // '8' = hexadecimal 38 = decimal 56
        byte    xByte  =  9;//  The following types are not CLS-compliant.
        ushort  xUshort = 120;   
        uint    xUint =   121;
        ulong   xUlong =  122;
        sbyte   xSbyte  = 123;//  The following type cannot be converted to an Int64.
    //  DateTime xDateTime = DateTime.Now;    Console.WriteLine(str, nl);
        Console.WriteLine("Boolean:  {0}", Convert.ToInt64(xBool));
        Console.WriteLine("Int16:    {0}", Convert.ToInt64(xShort));
        Console.WriteLine("Int32:    {0}", Convert.ToInt64(xInt));
        Console.WriteLine("Int64:    {0}", Convert.ToInt64(xLong));
        Console.WriteLine("Single:   {0}", Convert.ToInt64(xSingle));
        Console.WriteLine("Double:   {0}", Convert.ToInt64(xDouble));
        Console.WriteLine("Decimal:  {0}", Convert.ToInt64(xDecimal));
        Console.WriteLine("String:   {0}", Convert.ToInt64(xString));
        Console.WriteLine("Char:     {0}", Convert.ToInt64(xChar));
        Console.WriteLine("Byte:     {0}", Convert.ToInt64(xByte));
        Console.WriteLine("DateTime: There is no example of this conversion because");
        Console.WriteLine("          a DateTime cannot be converted to an Int64.");
    //
        Console.WriteLine("{0}The following types are not CLS-compliant.{0}", nl);
        Console.WriteLine("UInt16:   {0}", Convert.ToInt64(xUshort));
        Console.WriteLine("UInt32:   {0}", Convert.ToInt64(xUint));
        Console.WriteLine("UInt64:   {0}", Convert.ToInt64(xUlong));
        Console.WriteLine("SByte:    {0}", Convert.ToInt64(xSbyte));
        }
    }
      

  3.   

    string strT = (string)变量;
      

  4.   

    我定义的一个数组a[]想把他转换float型,怎么做呢??
      

  5.   

    我定义了一个字符串数组,想把他转换成float型的
    请问:此转换语句怎么写呢??谢谢!!
      

  6.   

    string [] s={"0.11","0.33","0.44"};
        double[] f=new double[3];
     for (int i=0;i<s.Length ;i++)
    {  
      f[i]=Convert.ToDouble(s[i]);
    } }
      

  7.   

    变量类型转换一般都会使用Convert函数更深奥的没接触过,一同等待高手!
      

  8.   

    string strT = (string)变量;
    string strT = (变量).tostring();int strT = (int)变量;
    int strT=Convert.int32(变量);有什么区别???????
      

  9.   

    to:boytomato(深爱一人叫颖的女孩!)
    不可以啊,错误提示为:
    输入字符串的格式不正确。