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.




9 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. Welcome to the future! Financing made easy with Prof. Mrs. DOROTHY LOAN INVESTMENTS

    Hello, Have you been looking for financing options for your new business plans, Are you seeking for a loan to expand your existing business, Do you find yourself in a bit of trouble with unpaid bills and you don’t know which way to go or where to turn to? Have you been turned down by your banks? MRS. DOROTHY JEAN INVESTMENTS says YES when your banks say NO. Contact us as we offer financial services at a low and affordable interest rate of 2% for long and short term loans. Interested applicants should contact us for further loan acquisition procedures via profdorothyinvestments@gmail.com

    I'm here to share an amazing life changing opportunity with you. its called Bitcoin / Forex trading options, Are you interested in earning a consistent income through binary/forex trade? or crypto currency trading. An investment of $200 can get you a return of $2,480 in 7 days of trading, We invest in all profitable projects with cryptocurrencies. We have excellent trading instruments and also support them with the best tools. Make as much as $1,000 or more every week with a starting capital of $200 to $350 You earn 100% of your initial profit every 7-14 business days and you get to do this from the comfort of your home/work. The truth is you must make profits trading in Cryptocurrency and investing in good signals with the best guidance from Crypto Coins Trading. Start investing with Crypto Coins Trading and start earning profitable interest quick without no doubt Payout weekly 100% guaranteed profit without any Hassles, It goes on and on The higher the investment, the higher the profits. Your investment is safe and secured and payouts assured 100%. if you wish to know more about investing in Cryptocurrency and earn daily, weekly OR Monthly in trading on bitcoin or any cryptocurrency and want a successful trade without losing Contact MRS.DOROTHY JEAN INVESTMENTS profdorothyinvestments@gmail.com

    categories of investment

    Cryptocurrency

    Loan Offer

    Mining Plan

    Business Finance Plan

    Binary option Trade Plan

    Forex trade Plan

    Stocks market Trade Plan

    Return on investment (ROI) Plan

    Gold and Silver Trade Plan

    Oil and Gas Trade Plan

    Diamond Trade Plan

    Agriculture Trade Plan

    Real Estate Trade Plan

    YOURS IN SERVICE
    Mrs. Dorothy Pilkenton Jean
    Financial Advisor on Bank Instruments,
    Private Banking and Client Services
    Email Address: profdorothyinvestments@gmail.com
    Operation: We provide Financial Service Such As Bank Instrument
    From AA Rate Banks, Cash Loan,BG,SBLC,BOND,PPP,MTN,TRADING,FUNDING MONETIZING etc.

    ReplyDelete
  6. 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...