Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using following code for checking that the string is equal to the string object of constructor or not using the following code

C#
for (int m = 0; m < CANMsgIdList.Count; m++)
     {
       if ((CANMsgIdList[m].MsgId) == fieldFromDB)
                                                
       string [] arr = (CANMsgIdList[m].TimeStamp).ToList;

      }


this CANMsgIdList is a list of constructor objects and contains 464523 objects in it

I am checking if any of the objects are equal to equal to string or not

If any object is equal to string then I need to copy the TimeStamp object of constructor to list array or list string

I am trying like this which is not working

Can anyone help me in solving this


Thanks
John
Posted

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.

C#
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.
 
Share this answer
 
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())
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900