0

I have this line of code:

var defaultResult = $"Enum_{@this.GetType().Name}_{@this}";

but I get this error:

expected ;

How do I fix this? String.Format?

6
  • Include some surrounding code, because this line is fine. Commented Sep 13, 2016 at 14:51
  • 1
    @kiziu Have you tried it? Because it's not. Commented Sep 13, 2016 at 14:53
  • @DrewKennedy nothing wrong with $, it marks an interpolated string. Besides the error is not about $ Commented Sep 13, 2016 at 14:56
  • I am not famous of the $ symbol, but I doubt if the @ could be placed inside {} Commented Sep 13, 2016 at 14:57
  • @Drew, my bad, a lesson for the future. Commented Sep 13, 2016 at 15:04

2 Answers 2

2

The $ is a feature available in C# 6.0. Make sure you're set to the correct version.

Sign up to request clarification or add additional context in comments.

2 Comments

The error doesn't mention $ at all. The older compilers would complain about $ not ;
I'm on C# 5.0 and I got the error about needing a ;.
0

String interpolation is supported onward c# 6.0. read here for more

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.