Notable roles in his career include the title character of Doogie Howser , M.D. , Barney Stinson in How I Met Your Mother , Col. Carl Jenkins in Starship Troopers , Dr. Horrible of the web series Dr. Horrible 's Sing-Along Blog , and as a fictionalized version of himself in Harold & Kumar Go to White Castle and its sequel Harold & Kumar Escape from Guantanamo Bay . Prominent roles of his career include the title role in Doogie Howser , M.D. , Colonel Carl Jenkins in Starship Troopers , the womanizing Barney Stinson in How I Met Your Mother , a fictionalized version of himself in the Harold & Kumar series , and the title role in Joss Whedon 's musical web series Dr. Horrible 's Sing-Along Blog .