Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:15:19+00:00 2026-06-05T01:15:19+00:00

Is it possible to get or set private fields? I want to get System.Guid.c

  • 0

Is it possible to get or set private fields?

I want to get System.Guid.c. Is there a way to access it or should I just copy the code from the strut and make the fields public?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:15:20+00:00Added an answer on June 5, 2026 at 1:15 am

    You can use reflection as suggested by Quantic Programming

    var guid = Guid.NewGuid();
    var field= typeof (Guid).GetField("_c", BindingFlags.NonPublic |BindingFlags.GetField | BindingFlags.Instance);
    var value = field.GetValue(guid);
    

    Although if you are okay with first converting the guid to a byte array, I might suggest:

    var guid = Guid.NewGuid();
    var c = BitConverter.ToInt16(guid.ToByteArray(), 6);
    

    The latter approach avoids using reflection.

    Edit

    You mention needing to be able to set the value as well, you can still avoid reflection:

    var guid = Guid.NewGuid();
    var guidBytes = guid.ToByteArray();
    
    // get value
    var c = BitConverter.ToInt16(guidBytes, 6);
    
    // set value
    Buffer.BlockCopy(BitConverter.GetBytes(c), 0, guidBytes, 6, sizeof(Int16));
    var modifiedGuid = new Guid(guidBytes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Get random item from array I need a code to set a
Is it possible to ignore set and get when I'm assigning to or retrieving
Is it possible to add XML comments for set and get accessors which will
Possible Duplicate: Differences between Private Fields and Private Properties Let's say I have a
In Spring 3 it is not possible to set @Autowired in either static fields
I want to do this: public Name { get; set { dosomething(); ??? =
Is it even possible? Say you have private Set<String> names = new LinkedHashSet<String>(); and
Possible Duplicate: List<T> readonly with a private set I have a class as: public
does anyone know how to (if possible) get the owner of the tag on
I am trying to work out if it is possible get JPA to persist

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.