© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•13mo ago•
15 replies
DaClownie

Accessing the value contained within a record struct

I have a
record struct
record struct
of
AssessmentResponse
AssessmentResponse
:
public record struct AssessmentResponse
    (
        Guid Id,
        string Name,
        int Type,
        DateTime DateStart,
        DateTime DateEnd
    );
public record struct AssessmentResponse
    (
        Guid Id,
        string Name,
        int Type,
        DateTime DateStart,
        DateTime DateEnd
    );

I understand this is an immutable object, in that once its been created it can't be modified... but how do I get access to the Id of this DTO for use in my code?
[Parameter]
public AssessmentResponse? ParentAssessment { get; set; }

Guid assessmentId = ParentAssessment.Id;
[Parameter]
public AssessmentResponse? ParentAssessment { get; set; }

Guid assessmentId = ParentAssessment.Id;

obviously the last line doesn't work but I'm not trying to modify the record struct, I just want access to the data.
I'm passing the
AssessmentResponse?
AssessmentResponse?
if it exists to the Blazor component, and want to access the Id section for the API call to update the record in my database. My
AssessmentService.Update
AssessmentService.Update
call requires an
Guid, AssessmentRequest
Guid, AssessmentRequest


I guess alternatively I could modify the AssessmentRequest to have an Id property contained within it and allow it to be nullable? but there's got to be a way to access the Id within the
record struct
record struct
and assign its value to another variable for use elsewhere.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

'The viewmanager.activeview must be a view contained within the viewmanager.window profile'
C#CC# / help
4y ago
❔ StructureMap.StructureMapException: StructureMap Exception Code: 207
C#CC# / help
3y ago
Difference between class, struct and record
C#CC# / help
3y ago