0
string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + false +  ")"

res[0] = "IRS5555"
res[1] = "IRS001"

このコードの出力は次のとおりです。

CalcAPI.GetXElementValue("IRS5555","IRS001",False)

でも私はしたい

CalcAPI.GetXElementValue("IRS5555","IRS001",false)

false小文字で。

完全なコードを提供していないことをお詫びします...falseは静的ではありません...

    public static object GetElementDataType(string DataType)
     {
         ///Write here methos for fetching data type of current element.
          object res = null;
         switch (DataType.ToLower())
          {
              case "int":
                 res = 0;
                 break;
              case "double":
                 res = 0.0;
                 break;
              case "string":
                 res = "";
                 break;
              case "myboolean":
                 res = false;
                 break;
              default:
                 res = "";
                 break;
          }
         return res;
     }

     string res1 = 
         "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," 
                                     + "\"" + res[1] + "\"" + ","  
                                     + GetElementDataType("myboolean") +  ")"

結果は

 CalcAPI.GetXElementValue("IRS5555","IRS001",False)

でも私はしたい

 CalcAPI.GetXElementValue("IRS5555","IRS001",false)

ダブルパスすれば

 string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("double") +  ")"

結果は

CalcAPI.GetXElementValue("IRS5555","IRS001",0)

でも私はしたい

CalcAPI.GetXElementValue("IRS5555","IRS001",0.0)

文字列を渡すと

string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("string") +  ")"

結果は

CalcAPI.GetXElementValue("IRS5555","IRS001",)

でも私はしたい

CalcAPI.GetXElementValue("IRS5555","IRS001","")
4

4 に答える 4

5

falseが一定の場合は、単純な文字列を使用できます。そして、文字列形式を使用することをお勧めします。

string res1 = string.Format("CalcAPI.GetXElementValue(\"{0}\",\"{1}\",false)", res[0], res[1]);
于 2012-08-27T08:29:27.123 に答える
1

を使用しfalse.ToString().ToLower()ます。

于 2012-08-27T08:26:44.783 に答える
0

このようにToLower()関数を使用します

  string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + false.ToString().ToLower() +  ")"
于 2012-08-27T08:26:37.700 に答える
0

で試してみてください

false.ToString().ToLower()
于 2012-08-27T08:27:55.610 に答える