I'll assume you're using a macro for the following answer.
To retrieve a user's current selection:
UIDocument uidoc = this.ActiveUIDocument;
SelElementSet selElSet = uidoc.Selection.Elements;
IEnumerable<Element> elements = (from Element el in selElSet select el);
To prompt a user to select an element:
UIDocument uidoc = this.ActiveUIDocument;
Reference reference = uidoc.Selection.PickObject(ObjectType.Element);
Element el = uidoc.Document.GetElement(reference);
Take a look at the Revit API samples, at the API documentation file (RevitAPI.chm), The Building Coder blog and the Boost Your BIM blog if you want some more information on how to get started.