Q:

C# Struct with same members but different names, how to solve?

I'm running into a problem in which I have two struct with the exact same member but different names (clear violation of DRY). The reason behind this is that struct A is the input to a function and struct B is the output of the function. The members of struct A and B are identically the same, but they represent different things. How would I solve this?
On the top of my head, I thought of having a parent base class, and then have A and B inherit it, but leave it empty.

More concretely, I'm working on a simple search and replace tool. The first function creates a list of SearchResults, each SearchResult contains startingIndex and text (the text that has been searched, may differ from one or another (think Regular Expressions)). Once these SearchResults are created, I can then pass them into a replace function that iterates through the SearchResult list and then replaces them. The output is a list of ReplaceResults - and inside this struct, it has also startingIndex and text (but the text is "the text after being replaced").
I'm learning C# and thought of this simple project to try.

A:

Couple options

Instead of having a SearchResult and a ReplaceResult struct, why not have a single struct, perhaps called IndexedTextItem that you use for both?
You could implement a IIndexedTextItem interface, and change SearchResult and ReplaceResult into classes which implement it.
Why not keep them separate?  They are different things after all.  Having two structs that have similar data types but serve different purposes is not necessarily a violation of DRY.  You may wish to extend one or the other in the future, e.g. perhaps you may need to add an OriginalText element to the ReplaceResult struct to support an "undo" feature later on down the road.

