You can achieve your goal in different ways. One is to use teletype family fonts \texttt{foobar()} as chrisS has mentioned in the comments. These are fixed-width fonts. Another option, is to use \emph{foobar()} style. Although in normal text '\emph{} seems to be italic, but it is actually more than that. For example, if your text is italic and you use \emph{foobar()} for your function, latex makes it visually distinct by making it normal text. In short, \emph{} guarantees a visual distinction but it is not necessary always pleasing.

Image from The Not So Short Introduction to LaTeX2ε.
My suggestion would be to define a macro of your own such as
\newcommand{\MyCode}[1]{%
\texttt{#1}}
And you it like The function \MyCode{fooBar()} does foo and bar...
This one has the advantage that in case you decide texttt is not what you want, you can change only your macro definition and the effect will apply to your whole document.
For longer pieces of the code, there are packages like listings that can you you with typesetting of different languages (e.g. this Q/A).
listingspackage. – Jun 09 '14 at 01:39\texttt{fooBar()}, which uses a monospaced font. – ChrisS Jun 09 '14 at 01:55\lstinline{fooBar()}to typeset it as some piece of code appearing somewhere in your text, e.g. even with logical markup. – Jun 09 '14 at 05:34listingsfor instance) ask Latex to use one character to “delimit” those parts of code, e.g.,The function |fooBar()| does foo and bar…. – Manuel Jun 09 '14 at 10:18