Say I have my class, and I have the non-static variable
int x = 5;
After the code runs x
is changed to something else, how can I get the value x
started with using reflection?
Say I have my class, and I have the non-static variable
int x = 5;
After the code runs x
is changed to something else, how can I get the value x
started with using reflection?
if i understand you correctly you want the initial value of the
x
. for that you need another member or parameter to keep the first initializing ofx
. for example in your class:Now if you mean default value that is set at class level, you already know as it is constant other way would be creating an instance of the class for which you need default value.
If you want list of transactional values you need to implement it, reflection is not meant for that.
Short answer: you can't.
If you implement some kind of custom transactional system, than it is possible. Out of the box: no luck.
And yes, the custom transactional system can be very simple: add another field or property that you use to 'remember' the initial value.