There are two basic types of elections, Primary and General, both are explained here.
Primary
A primary election is a selection of candidates that run for an office in the party in which they are registered and a voter can only vote for a candidate that is running in the same party primary in which he is registered.
At this time there are five recognized parties in the State of Maryland. They are Democrat, Republican, Green, Libertarians and Constitution. Independents and Declines are not considered a party. The major parties are required, by law, to choose their candidates for the General Election in a Party Primary election. Only registered voters who have affiliated with a major political party may vote in the Primary Election of their party. To vote in a party primary, you must affiliate with that party either when you register to vote or before the deadline to change party affiliation.
General
A general election is when the winner of the party primary and other party nominees run against each other. All voters are allowed to vote in a general election, regardless of your party affiliation. A voter may even vote for a candidate that is not of the same party as the voter. If a voter wished he/she may vote for candidates of every party that is listed on the ballot.