I'm not sure for C#, since I do not think there is a good way to say "if this object or that object" and still access the variables within it. What I would recommend doing though is writing a function that does all of the operations shared between both conditions, and then call the function with each input event by passing in the relevant data. For example:
void shared_function(Vector2 EventPosition, Int Index)
{
var parent = GetParent() as Sprite;
var distance_from_center = (EventPosition - parent.GetGlobalPosition()).Length();
// Etc
}
public override void _Input(InputEvent @event)
{
if (@event is InputEventScreenDrag DragEvent) {
shared_function(DragEvent.Position, DragEvent.GetIndex());
}
else if (@event is InputEventScreenTouch TouchEvent && @event.IsPressed()) {
shared_function(TouchEvent.Position, TouchEvent.GetIndex());
}
}