You need to sign in to do that
Don't have an account?
Class variable are not able to access dynamically
Hi All,
I am trying to access the class varible dynamically for one of my requirment. Please see the code.
public class CaseUpdateTestingClass {
public string AssetSN = '1AED45';
public string CDIDId='3498474';
public string ContactFirstName='SalesForce';
}
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
string a = 'AssetSN'; // Here I do dynamic assignment
system.debug('*********** : '+es.get(a));
Thanks
Shaijan Thomas
I am trying to access the class varible dynamically for one of my requirment. Please see the code.
public class CaseUpdateTestingClass {
public string AssetSN = '1AED45';
public string CDIDId='3498474';
public string ContactFirstName='SalesForce';
}
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
string a = 'AssetSN'; // Here I do dynamic assignment
system.debug('*********** : '+es.get(a));
Thanks
Shaijan Thomas
Regards
Amrender
Thanks for quick response
I update my scanario like this
CaseUpdateTestingClass es = new CaseUpdateTestingClass();
string ss = 'AssetSN;CDIDId;ContactFirstName'; // Here I do dynamic assignment
for ( string a : ss.split(';'))
system.debug('*********** : '+es.get(a));
AssestSN, CDIDId and ContactFirstName are the variables. Once we try to get the value, in this case it is treated as string and we will get exception. I dont think if it is possible in this way.
Regards
Amrender