[Tex/LaTex] How to use the degree symbol in programming listing


I'm using lyx and get the error message, that the ° symbol got excluded, when I'm trying the following example:


EDIT: as asked, here the latex code from lyx, where it is needed:

%% LyX 2.1.3 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.



\item \emph{class variables}\\
Public celsius() As Char = {" ", "°", "C", "/", "m", "i", "n"}
This variable is used to trim the output of Linkam functions, so numerical
value operation\emph{ }are possible with the outputs. It is made public,
so it can be accessed by functions outside this class, where the trimming
is nescessary.\\



Best Answer

Do you mean ${^\circ}$? This would give you the degree sign, when option mathescape is enabled.

And your script would look like this:


enter image description here