我写了一个web服务,在浏览器启动时工作正常.我在这个webservice中传递一个客户端ID,然后返回一个包含客户端名称的字符串,我们通过这样的字符串:http://prntscr.com/8c1g9z
我创建服务的代码是:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
namespace RESTService.Lib
{
[ServiceContract(Name = "RESTDemoServices")]
public interface IRESTDemoServices
{
[OperationContract]
[WebGet(UriTemplate = "/Client/{id}", BodyStyle = WebMessageBodyStyle.Bare)]
string GetClientNameById(string Id);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single, IncludeExceptionDetailInFaults = true)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class RestDemoServices:IRESTDemoServices
{
public string GetClientNameById(string Id)
{
return ("Le nom de client est Jack et id est : " +Id);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但我无法消耗它.我的代码是:
using System; …Run Code Online (Sandbox Code Playgroud) 我知道c#只是在Console.WriteLine中保存双引号内的数据("当我打印时,这两个双引号被删除");
它在控制台中的输出将是:
Console.WriteLine("These two double quotes are removed when i am printed");`
Run Code Online (Sandbox Code Playgroud)
但我想在控制台上打印的内容与双引号相同:
Console.WriteLine("These two double quotes are removed when i am printed");`
Run Code Online (Sandbox Code Playgroud)
这该怎么做.我这样做是因为我必须将此输出写入双引号具有重要性的文件.