Using GetComponent without knowing the script name?

I’ve seen this asked a few times without any real resolution and I am now thinking that this simply isn’t supported. What I would like to do is use GetComponent to assign a variable in the selected object’s script but since a number of different objects with different scripts could be selected ‘SomeScriptName’ is not going to be known.

selectedObject.GetComponent<SomeScriptName>().someVariable = "Example";

I am aware that I can just use SendMessage instead and this may be a better solution all around but after some experimentation I found I can use this to get the name of the script:

Type scriptNameTest = selectedObject.GetComponent<MonoBehaviour>().GetType();

Provided that I have using System; in there or use System.Type scriptNameTest That will return ‘SomeScriptName’ for whichever object is selected. The name of the script can be printed correctly so it seemed logical enough just to do this with that information:

selectedObject.GetComponent<scriptNameTest>().someVariable = "Example";

However that will return an error of 'scriptNameTest' is a variable but is used like a type.

If I declare scriptNameTest globally rather than locally it will return an error of The type or namespace name 'scriptNameTest' could not be found (are you missing a using directive or an assembly reference?)

So I am assuming that it just isn’t possible to use a variable as a class in a GetComponent but I am also quite new to C# so it is quite possible I’ve just missed something. It seems sort of like an unnecessary limitation to me though. I know there are lots of other ways I could achieve this but it would just be so simple to use this method if it actually worked…

As hexagonius said, you could implement an Interface containing a property all these objects should have in common, like an identifier (e.g. enum). You would search for the interface and get any script attached to that object which derives from that Interface.
Then you could just check the property for which script you have found.
Though I’m not sure whether calling methods that are not predefined by the Interface will work.