C# 字符串串联

C# 字符串串联,c#,C#,在 此代码的输出为: res[0] = "IRS5555" res[1] = "IRS001" 但是我想要 CalcAPI.GetXElementValue("IRS5555","IRS001",False) false小写 很抱歉没有提供完整的代码。。。 false不是静态的 CalcAPI.GetXElementValue("IRS5555","IRS001",false) 结果是 public static object GetElementDataType(string D

此代码的输出为:

res[0] = "IRS5555"
res[1] = "IRS001"
但是我想要

CalcAPI.GetXElementValue("IRS5555","IRS001",False)
false
小写

很抱歉没有提供完整的代码。。。 false不是静态的

CalcAPI.GetXElementValue("IRS5555","IRS001",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") +  ")"
 string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("double") +  ")"
string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("string") +  ")"
但是我想要

 CalcAPI.GetXElementValue("IRS5555","IRS001",False)
CalcAPI.GetXElementValue("IRS5555","IRS001",0)
CalcAPI.GetXElementValue("IRS5555","IRS001",)
如果我通过双关

 CalcAPI.GetXElementValue("IRS5555","IRS001",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") +  ")"
 string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("double") +  ")"
string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("string") +  ")"
但是我想要

 CalcAPI.GetXElementValue("IRS5555","IRS001",False)
CalcAPI.GetXElementValue("IRS5555","IRS001",0)
CalcAPI.GetXElementValue("IRS5555","IRS001",)
如果我传递字符串

CalcAPI.GetXElementValue("IRS5555","IRS001",0.0)
结果是

    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") +  ")"
 string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("double") +  ")"
string res1 = "CalcAPI.GetXElementValue(" + "\"" + res[0] + "\"" + "," + "\"" + res[1] + "\"" + ","  + GetElementDataType("string") +  ")"
但是我想要

 CalcAPI.GetXElementValue("IRS5555","IRS001",False)
CalcAPI.GetXElementValue("IRS5555","IRS001",0)
CalcAPI.GetXElementValue("IRS5555","IRS001",)
像这样使用ToLower()函数

CalcAPI.GetXElementValue("IRS5555","IRS001","")
像这样使用ToLower()函数

CalcAPI.GetXElementValue("IRS5555","IRS001","")
使用
false.ToString()

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

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

如果false是常量,那么可以使用简单字符串。最好使用字符串格式:

false.ToString().ToLower()

如果false是常量,那么可以使用简单字符串。最好使用字符串格式:

false.ToString().ToLower()

如何处理
string res1=“CalcAPI.GetXElementValue”(“+”\”“+res[0]+“+”,“+”\”“+res[1]+“\”“+”,false)”
?如何处理
string res1=“CalcAPI.GetXElementValue”(“+”\”“+res[0]+“+”,“+”\”“+res[1]+“+”,false)”
?Jensen在ToString的末尾添加括号();Jensen在ToString的末尾添加括号();