I have a code to read data block inside MIFARE card.
The method rfidM1.ReadDataFromCardM1 will read a block and return value in string.
string memQuery = string.Empty;
int i = 0, j = 0;
sector = 4;
block = 4;
for (i = 0; i < block; i++)
{
for (j = 0; j < sector; j++)
{
memQuery += rfidM1.ReadDataFromCardM1(Convert.ToByte(j), Convert.ToByte(i), _Key1) + ",";
}
}
My intention is concating memQuery with comma. Example output here:
,0,,,,,True,,C0-12320,0,,,,,,
I concat memQuery with various ways, for example, using +=, StringBuilder or ArrayList but they didn't work because it always has an output like this when I put it in MessageBox.
,0
It looks like string after that 0 cannot concat with other string after it. Why?
List<string>(which contains real strings) instead of anArrayList(which contains justobjects)memQuery.Add. Is that a collection? Try refactoring your code. What are thevariablesand values you want to concat to that string?K? You're near it smells weird near that.ToString().Replace(). Try creating different methods for each purpose so it will be easier to debug the problem.forstatement is inside it:for (int i=0; .... And you could also declare it asbyteif that is what you really needmemQuery[k]returns null, you will get a NullReferenceException when trying to execute any method on it, such as GetType() or ToString(). Could thatReadDataFromCardM1returnnulls or control characters?