How to get the memory address of a string in C#? -
could show me way memory address of string in c#? example, in:
string = "qwer"; i need memory address of a.
you need fix string in memory using fixed keyword , reference memory address using char*
using system; class program { static void main() { console.writeline(transform()); console.writeline(transform()); console.writeline(transform()); } unsafe static string transform() { // random string. string value = system.io.path.getrandomfilename(); // use fixed statement on char pointer. // ... pointer points memory won't moved! fixed (char* pointer = value) { // add 1 each of characters. (int = 0; pointer[i] != '\0'; ++i) { pointer[i]++; } // return mutated string. return new string(pointer); } } } output
**61c4eu6h/zt1
ctqqu62e/r2v
gb{kvhn6/xwq**
| lets take situation surprised about:
both now if did same ints, should not suprised: comparing references now understand | ||||
| |