2017-08-31 90 views
0
//Rextester.Program.Main is the entry point for your code. Don't change it. 
//Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text.RegularExpressions; 

namespace Rextester 
{ 
    public class Program 
    { 
     public static void Main(string[] args) 
     { 
      var type = "Fighter" 
      var VType = $"{type}_(192.168.1.90)"; 

      //Your code goes here 
      Console.WriteLine(VType); 
     } 
    } 
} 

我想在C#中使用online C# compiler的字符串插值。它給了我一個錯誤,Unexpected character '$'在C中的字符串插值#

我在做什麼錯?

+6

很可能你使用的是舊版本的c#/ VS –

+3

嗯,它說*不要改變*。你改變了它。在線編譯器不值得你花時間,你可以在你的機器上得到一個理解這種語法的程序。 –

回答

5

您鏈接到的網站支持C#的過時版本,該版本不支持您使用的字符串插值,即introduced in C# 6