Our finished basement has electric baseboard heat. The baseboard is powered by a light switch, so I either have the heat on or off. Can I take out the switch and use the wiring to connect a digital thermostat instead?
What you need is a line voltage thermostat. Non--programmable ones are very common. Programmable (digital as you call it) line voltage stats are available but rare. I attached a pic of one that I found. Search for "line voltage thermostat" and you'll find a few. If you don't care about programability, simple line voltage stats are as common as dirt. Just be sure it's two pole. I don't know if single pole stats are still available, but for 240, I don't consider them safe.
Not sure what NoSparksPlease was getting at regarding the disconnecting switch (???), I would assume the existing circuit is on a breaker and that would satisfy the code.
You normally can, but not every digital thermostat will work. You will need to select one that specifies the proper voltage (120 or 240v), most digital thermostats are only rated for 24v or less, and some digital stats require a neutral, which may not be present if two wire cable was used on a 240v circuit.
Most line voltage digital thermostats do not satisfy electrical code requirements that may require an electrical disconnecting switch, so you may have to install a bracket in your electrical panel to make it so you can lock the breaker in the off position.
Also my recollection and checking with a couple online manufacturers webpages is the Installation Instructions that come with baseboards specify either using a built in or wall thermostat. The Installation instructions are part of the NRTL Listing (UL, ETL. CSA), and the electrical codes require following the those instructions. So it is likely that you existing installation is not legal.