Skip to content
Discussion options

You must be logged in to vote

You can write a helper method to shallow-copy the fields via reflection. A source generator could write that for you. The compiler itself couldn't emit that code because you wouldn't have access to the private fields of Student from EnhancedStudent, and if Student is defined in a different assembly the schema could be different at runtime.

Replies: 6 comments 11 replies

Comment options

You must be logged in to vote
3 replies
@jnm2
Comment options

jnm2 Nov 6, 2025
Collaborator

@The-Futurist
Comment options

@HaloFour
Comment options

Answer selected by The-Futurist
Comment options

You must be logged in to vote
5 replies
@The-Futurist
Comment options

@martin-steinhoefer
Comment options

@franchyd
Comment options

@timcassell
Comment options

@franchyd
Comment options

Comment options

You must be logged in to vote
3 replies
@martin-steinhoefer
Comment options

@huoyaoyuan
Comment options

@martin-steinhoefer
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
7 participants