This is a migrated thread and some comments may be shown as answers.

Compile error while combining two variables to a string

2 Answers 47 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jiyoon
Top achievements
Rank 1
Jiyoon asked on 20 Jul 2018, 08:53 PM

I have a line of code to combine two variables:

string expectedValue = $"{testVariable1}-{testVariable2}";

This works fine when I execute this from Visual Studio plug-in but I get an compile error in Test Studio with a message, ": error CS1056: Unexpected character '$'".  Is this a known issue?

 

Thanks,

-Jiyoon

2 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 25 Jul 2018, 09:18 AM
Hi Jiyoon,

Thank you for reaching us out. 

The reason you have encountered that error is that Test Studio and Visual Studio compile the code with different engines. To be able to compile that code with Test Studio you will need to downgrade it to be compatible with C#5. 

I hope this is helpful for you! 

Regards,
Elena Tsvetkova
Progress Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Elena
Telerik team
answered on 16 Oct 2020, 01:02 PM

Hi Jiyoon,

I was accidentally pointed to this public forum post and noticed that the provided information is not quite descriptive for the issue you have encountered. Therefore I decided to update it accordingly, although you should have figured this out long time ago. 

The issue you have encountered back in the days is related to the minimum version of .Net framework, which Test Studio targets, is .Net 4.5. This version of the .Net framework works with C#5 compile engine and the interpolation of strings used in the code snippet, is not introduced for this engine. 

So, to avoid similar issues, you need to change the code with such, that is compatible with the C#5 compile engine. I checked what should be used instead of the string interpolation and that seems to be the String.Format() method

Regards,
Elena
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
General Discussions
Asked by
Jiyoon
Top achievements
Rank 1
Answers by
Elena
Telerik team
Share this question
or