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

Compile error while combining two variables to a string

2 Answers 77 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

Khushboo
Top achievements
Rank 1
commented on 11 Sep 2023, 11:59 AM

Please suggest what should be the required .Net Framework version?
Elena
Telerik team
commented on 11 Sep 2023, 01:02 PM

Hi Khushboo, 

Currently Test Studio projects target .Net Framework 4.7.2. The corresponding C# language version is C#7.3. I hope this answers your question. 

Don't hesitate to follow up in case you have any additional questions.

Khushboo
Top achievements
Rank 1
commented on 11 Sep 2023, 03:58 PM

Hello Elena,

I already have 4.6 installed but Telerik test Studio is not compiling my code, give error - CS1056: Unexpected character '$'"

Do you have any pointers?

 

Elena
Telerik team
commented on 14 Sep 2023, 09:40 AM

Hi Khushboo, 

Please, take the time to follow up on your private support thread, or to the other forum post you submitted on the same topic.

Regards,
Elena

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