c# - Incrementing a pointer inside a fixed block prohibited, it seems it should work -
i error trying increment pointer.
cannot assign ptr because fixed variable cs1656 same error other pointer ptruc
unsafe void organize_data() { fixed(byte* ptr = &database[0]) { fixed(byte* ptruc = &dtbaseuc[0]) { strcnt=1; linestrts[0]=0; for(int i=0;i<filelen;i++) { if(*ptr > 96 && *ptr < 123)*ptruc=(byte)((int)*ptr-(int)32); if(*ptr ==13) { linestrts[strcnt]=i+1; strcnt++; } ptr++; ptruc++; } } } textbox2.text=strcnt.tostring(); }
variables declared in fixed
block read-only , cannot assigned to. must instead copy pointer , increment copy.
fixed (byte* ptr = &database[0]) { byte* dbptr = ptr; ptr++; // cs1656, ptr read-only. dbptr++; // valid. }
Comments
Post a Comment