且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将字符串转换为列表字符串或列表数组

更新时间:2022-02-01 05:43:19

如果您正在使用字符串数组,那么您需要在声明时定义数组的大小,这不能修改。而是使用arraylist。



If you are using array of string then you need to define the size of the array while declaration and this can't be modified. Instead use an arraylist.

ArrayList arrLst1 = new ArrayList();
for (int m = 0; m < CANMsgIdList.Count; m++)
     {
       if ((CANMsgIdList[m].MsgId) == fieldFromDB)
                                                
       arrList1.Add(CANMsgIdList[m].TimeStamp.Tostring());
 
      }





希望这应该有用。



Hope this should work.


不确定你的意思是,你的对象是字符串还是其他类型。与字符串类型比较时,您的对象可能需要将其转换为字符串。

not sure what your saying, is your object a string or another type. Your object may require that you cast it to a string when comparing to a string type.
//try converting/casting to a string type
if (CANMsgIdList[m].MsgId.toString() == fieldFromDB.toString())