The following (other than the \setcounter{secnumdepth}{0}) is taken from User math's answer in Underline the section title text in table of contents.
\documentclass{article}
\usepackage{titletoc}
% The line below seems to be incompatible with the underlining of the line beneath it
% \setcounter{secnumdepth}{0}
\titlecontents{section}{\thecontentslabel\quad}{\underline}{}{\hfill\thecontentspage}
\begin{document}
\tableofcontents
\section{Foobar}
\end{document}
If one un-comments the commented line of code, one can not have both \setcounter{secnumdepth}{0}, and have the underlining working at the same time.
I wonder why, and whether there is a way to circumvent this, without resorting to the soulpackage (as had done User math in his answer; and others; in the mentioned OP), thus by still using the 2 currently incompatible lines up to a great extent at least.

\usepackage{hyperref}though... – O0123 May 25 '16 at 06:21\usepackage{hyperref}) in your MWE, then it is no longer compilable (I'm on Texshop, using LaTeX as a Program, where it still compiles once, but not twice and more). I get the following error, from the .toc:\hyper@linkstart has an extra }. – O0123 May 25 '16 at 09:25