
{"id":279,"date":"2023-07-07T09:33:00","date_gmt":"2023-07-07T08:33:00","guid":{"rendered":"https:\/\/ishooscode.com\/?p=279"},"modified":"2023-07-07T09:35:13","modified_gmt":"2023-07-07T08:35:13","slug":"access-private-member","status":"publish","type":"post","link":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/","title":{"rendered":"How to access private member of class"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This article reflect on how to access private member of class. There are multiple routes to achieve this but in this article we will focus on the right approach.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Setting or getting private variable is quite a corner scenario while developing new application. Developers always find a work around to make the data available in private member to them. However, There is a more efficient and recommended mechanism to access private member. Here we can access the private variable using reflection and in built microsoft libraries.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Real-world scenario where access private member is required?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In real-world, it is possible that you never encounter such scenario where there is a need to access private variable. Nevertheless, If you do then you\u2019ll simply change access specifier for the member.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In UTC or TDD development you might find yourself in scenario where you need to access or change the value of private variable of a class. In UTCs we often do such things to re-create negative scenario. We might need to access private variable of a third-party variable to generate desirable result.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How can we access private member of class?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Quite simple, you just need to do some R&amp;D with reflection classes and need to spend some time with <strong>Type<\/strong> class provided in .net .<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System;\r\nusing System.Collections;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\nusing System.Text;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace CrossProjectDemo\r\n{\r\n    public class Car : IEnumerable\r\n    {\r\n        private string name = string.Empty;\r\n        private string prvtVariable = \"PrivateVariable\";\r\n\r\n        public string Name {\r\n            get { return name; }\r\n            set { name = value; }\r\n        }\r\n\r\n    }\r\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see, here are two private variables,<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>name<\/li>\n\n\n\n<li>prvtVariable&nbsp;<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">While name is being accessed in a public Property Name, prvtVariable will be accessed directly<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Let\u2019s see how,<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First in your application import Reflection<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System.Reflection;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then follow the code,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Car c = new Car();\nType typ = typeof(Car);\nFieldInfo type = typ.GetField(\"prvtVariable\", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);\nvar value = type.GetValue(c);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">C#Copy<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/f4n3x6c5.stackpathcdn.com\/UploadFile\/BlogImages\/10102019094545AM\/PrivateVarGet.PNG\" alt=\"Access private member\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the above image, you can see the type.IsPrivate is true which means the variable is private,<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/f4n3x6c5.stackpathcdn.com\/UploadFile\/BlogImages\/10102019094545AM\/PrivateVarGet1.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And we can access its value into the value variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s easy right.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Write to private member<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, Let\u2019s move towards how we can change its value. Lets\u2019 make few changes to the existing code<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just add one-line right after Getvalue() method call,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>var value = type.GetValue(c);\ntype.SetValue(c, \"Not so much\");<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and now you have changed the value of a private variable,<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/f4n3x6c5.stackpathcdn.com\/UploadFile\/BlogImages\/10102019094545AM\/PrivateVarset.PNG\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Easy, isn\u2019t it. So here we\u2019re accessing private variables through reflection.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For details on reflection visit microsoft learner site <a href=\"https:\/\/learn.microsoft.com\/en-us\/dotnet\/csharp\/advanced-topics\/reflection-and-attributes\/\" title=\"here\">here<\/a>. Cheers!!!<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">More posts like this<\/h4>\n\n\n<ul class=\"wp-block-latest-posts__list wp-block-latest-posts is-layout-flow wp-block-latest-posts-is-layout-flow\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/12\/13\/introduction-to-azure-cosmos-db\/\">Introduction to Azure Cosmos DB<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/09\/02\/enhancing-app-security-with-azure-managed-identities\/\">Enhancing app security with Azure Managed Identities<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/08\/23\/comparing-performance-of-lists\/\">IL code performance of Generic List And Non Generic List<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/07\/30\/how-does-a-dictionary-maintains-data\/\">How does a dictionary maintains data<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/07\/12\/enumerator-or-foreach\/\">What is better between Enumerator or foreach<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>This article reflect on how to access private member of class. There are multiple routes to achieve this but in this article we will focus on the right approach. Introduction Setting or getting private variable is quite a corner scenario while developing new application. Developers always find a work around to make the data available [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":281,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"wpai_generated_summary":"","wpai_tts_display_audio":true,"footnotes":""},"categories":[22,59],"tags":[20,15,60],"class_list":["post-279","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-c-sharp","category-reflection","tag-net","tag-c","tag-reflection"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.4 - aioseo.com -->\n\t<meta name=\"description\" content=\"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"ishooagarwal@gmail.com\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/\" \/>\n\t\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.4\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ishoo&#039;s Code -\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to access private member of class\" \/>\n\t\t<meta property=\"og:description\" content=\"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2023-07-07T08:33:00+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2023-07-07T08:35:13+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to access private member of class\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#blogposting\",\"name\":\"How to access private member of class\",\"headline\":\"How to access private member of class\",\"author\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/author\\\/ishooagarwalgmail-com\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/ishooscode.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/PrivateMemberOfClass.png\",\"width\":1017,\"height\":529,\"caption\":\"Private member of class\"},\"datePublished\":\"2023-07-07T09:33:00+01:00\",\"dateModified\":\"2023-07-07T09:35:13+01:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#webpage\"},\"articleSection\":\"C#, Reflection, .net, c#, Reflection\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ishooscode.com\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/category\\\/c-sharp\\\/#listItem\",\"name\":\"C#\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/category\\\/c-sharp\\\/#listItem\",\"position\":2,\"name\":\"C#\",\"item\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/category\\\/c-sharp\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#listItem\",\"name\":\"How to access private member of class\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#listItem\",\"position\":3,\"name\":\"How to access private member of class\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/category\\\/c-sharp\\\/#listItem\",\"name\":\"C#\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#person\",\"name\":\"ishooagarwal@gmail.com\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0ea4396d285fbb3d9c79bf9c2073c85d136b778750ab18d6edb4f53eb3ee18a9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"ishooagarwal@gmail.com\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/author\\\/ishooagarwalgmail-com\\\/#author\",\"url\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/author\\\/ishooagarwalgmail-com\\\/\",\"name\":\"ishooagarwal@gmail.com\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0ea4396d285fbb3d9c79bf9c2073c85d136b778750ab18d6edb4f53eb3ee18a9?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"ishooagarwal@gmail.com\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#webpage\",\"url\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/\",\"name\":\"How to access private member of class\",\"description\":\"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/author\\\/ishooagarwalgmail-com\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/author\\\/ishooagarwalgmail-com\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/ishooscode.com\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/PrivateMemberOfClass.png\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#mainImage\",\"width\":1017,\"height\":529,\"caption\":\"Private member of class\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/index.php\\\/2023\\\/07\\\/07\\\/access-private-member\\\/#mainImage\"},\"datePublished\":\"2023-07-07T09:33:00+01:00\",\"dateModified\":\"2023-07-07T09:35:13+01:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#website\",\"url\":\"https:\\\/\\\/ishooscode.com\\\/\",\"name\":\"ishooscode.com\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/ishooscode.com\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to access private member of class","description":"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java","canonical_url":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#blogposting","name":"How to access private member of class","headline":"How to access private member of class","author":{"@id":"https:\/\/ishooscode.com\/index.php\/author\/ishooagarwalgmail-com\/#author"},"publisher":{"@id":"https:\/\/ishooscode.com\/#person"},"image":{"@type":"ImageObject","url":"https:\/\/ishooscode.com\/wp-content\/uploads\/2023\/07\/PrivateMemberOfClass.png","width":1017,"height":529,"caption":"Private member of class"},"datePublished":"2023-07-07T09:33:00+01:00","dateModified":"2023-07-07T09:35:13+01:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#webpage"},"isPartOf":{"@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#webpage"},"articleSection":"C#, Reflection, .net, c#, Reflection"},{"@type":"BreadcrumbList","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/#listItem","position":1,"name":"Home","item":"https:\/\/ishooscode.com\/","nextItem":{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/#listItem","name":"C#"}},{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/#listItem","position":2,"name":"C#","item":"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/","nextItem":{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#listItem","name":"How to access private member of class"},"previousItem":{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#listItem","position":3,"name":"How to access private member of class","previousItem":{"@type":"ListItem","@id":"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/#listItem","name":"C#"}}]},{"@type":"Person","@id":"https:\/\/ishooscode.com\/#person","name":"ishooagarwal@gmail.com","image":{"@type":"ImageObject","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/0ea4396d285fbb3d9c79bf9c2073c85d136b778750ab18d6edb4f53eb3ee18a9?s=96&d=mm&r=g","width":96,"height":96,"caption":"ishooagarwal@gmail.com"}},{"@type":"Person","@id":"https:\/\/ishooscode.com\/index.php\/author\/ishooagarwalgmail-com\/#author","url":"https:\/\/ishooscode.com\/index.php\/author\/ishooagarwalgmail-com\/","name":"ishooagarwal@gmail.com","image":{"@type":"ImageObject","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0ea4396d285fbb3d9c79bf9c2073c85d136b778750ab18d6edb4f53eb3ee18a9?s=96&d=mm&r=g","width":96,"height":96,"caption":"ishooagarwal@gmail.com"}},{"@type":"WebPage","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#webpage","url":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/","name":"How to access private member of class","description":"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/ishooscode.com\/#website"},"breadcrumb":{"@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#breadcrumblist"},"author":{"@id":"https:\/\/ishooscode.com\/index.php\/author\/ishooagarwalgmail-com\/#author"},"creator":{"@id":"https:\/\/ishooscode.com\/index.php\/author\/ishooagarwalgmail-com\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/ishooscode.com\/wp-content\/uploads\/2023\/07\/PrivateMemberOfClass.png","@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#mainImage","width":1017,"height":529,"caption":"Private member of class"},"primaryImageOfPage":{"@id":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/#mainImage"},"datePublished":"2023-07-07T09:33:00+01:00","dateModified":"2023-07-07T09:35:13+01:00"},{"@type":"WebSite","@id":"https:\/\/ishooscode.com\/#website","url":"https:\/\/ishooscode.com\/","name":"ishooscode.com","inLanguage":"en-US","publisher":{"@id":"https:\/\/ishooscode.com\/#person"}}]},"og:locale":"en_US","og:site_name":"Ishoo's Code -","og:type":"article","og:title":"How to access private member of class","og:description":"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java","og:url":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/","article:published_time":"2023-07-07T08:33:00+00:00","article:modified_time":"2023-07-07T08:35:13+00:00","twitter:card":"summary_large_image","twitter:title":"How to access private member of class","twitter:description":"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java"},"aioseo_meta_data":{"post_id":"279","title":"How to access private member of class","description":"Access private member | Reflection | Dot Net | C# | C Sharp | Read data from private variable | Write data to private variable | Class | Private | Java","keywords":[],"keyphrases":{"focus":{"keyphrase":"access private member","score":100,"analysis":{"keyphraseInTitle":{"score":9,"maxScore":9,"error":0},"keyphraseInDescription":{"score":9,"maxScore":9,"error":0},"keyphraseLength":{"score":9,"maxScore":9,"error":0,"length":3},"keyphraseInURL":{"score":5,"maxScore":5,"error":0},"keyphraseInIntroduction":{"score":9,"maxScore":9,"error":0},"keyphraseInSubHeadings":{"score":9,"maxScore":9,"error":0},"keyphraseInImageAlt":{"score":9,"maxScore":9,"error":0}}},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":[],"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":null,"frequency":"default","local_seo":null,"limit_modified_date":false,"created":"2023-07-07 08:33:04","updated":"2026-11-03 09:44:09","focus_keyword":"access private member","additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/ishooscode.com\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/\" title=\"C#\">C#<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to access private member of class\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/ishooscode.com\/"},{"label":"C#","link":"https:\/\/ishooscode.com\/index.php\/category\/c-sharp\/"},{"label":"How to access private member of class","link":"https:\/\/ishooscode.com\/index.php\/2023\/07\/07\/access-private-member\/"}],"_links":{"self":[{"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/posts\/279","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/comments?post=279"}],"version-history":[{"count":2,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/posts\/279\/revisions"}],"predecessor-version":[{"id":308,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/posts\/279\/revisions\/308"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/media\/281"}],"wp:attachment":[{"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/media?parent=279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/categories?post=279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ishooscode.com\/index.php\/wp-json\/wp\/v2\/tags?post=279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}