Private, Protected and Public attribute access in Class Extension


Private, Protected, and Public attribute access in Class Extension


lots of developers faced the issue on the daily basis during development to access private, protected, and public methods.

As everyone knows that public attribute is available to access with the class instance.
but protected and private attributes are a little difficult to access.

In this demo, we show how to access all 3 access modifiers using the class extension.


Step-1 Create a class SLD_DemoClass.
Step-2 Declare 3 variables like below and one public method to set values in these variables.






Step-3 Now create an Extension of this class with SLD_DemoClass_Extension.
Step-4 Create a getter setter to access the variable.



for public and protected methods it's easy to access just to write simple getter setter method and can access these public methods using class instance.

Step-5 To Access the private attributes in-class extension, We need to use the C# reflection library.

Step-6 Now write the below code to access the private attribute on run-time.





following is the screenshot of the complete code of the extension class.




Step-7 Now create a run-able class and action menu item to execute this code.





Step-8 perform build & Sync and login on D365FO for verification.



You can check in the screenshot all 3  protected, private, and public attributes values in the info message.


Please feel free to contact me if you are facing any issues during the implementation of this blog.




Support Faryal's Cusine


8 comments:

  1. Hi,

    What is the role of objPrivateStringExt ? is this attribute extension of objPrivateString ?

    ReplyDelete
    Replies
    1. Yes, "objPrivateString" is extension attribute.

      I am using "objPrivateStringExt" as journal attribute to not use getter setter again and again.

      Delete
    2. What has your government done to help save you from your financial instability? you strive to survive and yet you hear stories of how your leaders have become terror in your entities... is time to make a different. for will have made money, and we have also come to help you out from your long time of financial suffering. clearing of credit card is made available, software for hacking ATM machines, bank to bank hacking and transfer, change your school grade and become something useful in the society. we also have other form of services such as Facebook hack, whats-app hack, twitter hack, i cloud hack, tracking of smart phones, hacking CCTV, installation of software on desktop and PC, snap-chat hack, Skype hack, wire wire, bitcoin account hack, erase your criminal record and be free for ever. database hack and many more. e-mail: cyberhackingcompany@gmail.com for your genuine hacking services and we shock we your findings.  

      Delete
    3. Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download Now

      >>>>> Download Full

      Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download LINK

      >>>>> Download Now

      Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download Full

      >>>>> Download LINK Oy

      Delete
  2. INSTANT AFFORDABLE PERSONAL/BUSINESS/HOME/INVESTMENT LOAN OFFER WITHOUT COST/STRESS CONTACT US TODAY VIA Whatsapp +19292227023 Email drbenjaminfinance@gmail.com

    Hello, Do you need an urgent loan to support your business or in any purpose? we are certified and legitimate and international licensed loan Company. We offer loans to Business firms, companies and individuals at an affordable interest rate of 2% , It might be a short or long term loan or even if you have poor credit, we shall process your loan as soon as we receive your application. we are an independent financial institution. We have built up an excellent reputation over the years in providing various types of loans to thousands of our customers. We Offer guaranteed loan services of any amount to people all over the globe, we offer easy Personal loans,Commercial/business loan,Car loan Leasing/equipment finance, Debt consolidation loan, Home loan, ETC with either a good or bad credit history. If you are in need of a loan do contact us via Whatsapp +19292227023 Email drbenjaminfinance@gmail.com

    Share this to help a soul right now, Thanks

    ReplyDelete
  3. One evening, i was reading a blog of how so many people got this blank card online when i was trying to search for a new job, but it didn't seem clear to me so i ignored. Three days later, i was so surprised to see a comment by my cousin on how he got the blank card worth Thousand Dollars and without hesitation i gave him a call to come over to the house to tell me more about the card and he told me that its a miracle that i needed to per-take. He gave me the email address of the hackers and i contact them for the card and they responded and told me all the procedures and terms of the card which was also what my cousin told me, i agreed and completed their requirement to get the card. Four days later, i heard knock on my door an behold was the courier agent who brought the parcel to my house and today i am rich and i thank God to this hackers and to my cousin brother who lead me to them. It might sounds odd but you can get yours via email: darkwebcyberhackers@gmail.com OR darkwebcyberhackers@yahoo.com or WhatsApp: +18033921735

    ReplyDelete
  4. Are you new to stocks and cypto currency trading and want to be successful in your trade if yes then get help from the most down to earth and reliable expert trader I has been managing trading account for some time now and I can proudly say I make Good withdrawals monthly of $5000 Kindly reply back for more information on how to trade Contact via whatsapp +447883246472 email: tdameritrade077@gmail.com

    ReplyDelete
  5. Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download Now

    >>>>> Download Full

    Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download LINK

    >>>>> Download Now

    Dynamics 365 Finance And Operations Talk: Private, Protected And Public Attribute Access In Class Extension >>>>> Download Full

    >>>>> Download LINK

    ReplyDelete

Virtual Fields Vs Computed Fields

  Virtual Field: A virtual field in D365FO is a field that doesn't have a direct representation in the database. It's a field that y...