欧元符号(€)未显示在Console.WriteLine中 [英] Euro symbol (€) does not show up in Console.WriteLine

查看:113
本文介绍了欧元符号(€)未显示在Console.WriteLine中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在代码中写入欧元符号(€)?

How can I write the Euro symbol (€) within my code?

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

namespace ConsoleApplication2
{
       public class TaxableProduct : Product
{

           public TaxableProduct(String productDescription, decimal price)
           {
               this.Price = price;
               this.ProductDescription = productDescription;   
           }

           protected decimal taxRate = 1.18M; 
public void setTaxRate(decimal value) 
{
    this.taxRate = value;
}
public decimal getTaxRate() { return this.taxRate; }

public decimal getTotalPrice
{
        get
            {
                // The code can access the Price property because it's
                //a publicpartofthebaseclass Product.
                //Thecodecannotaccesstheprivate price variable, however.
                return(Price * taxRate);
            }
        }
}

public class Product
{
    public Product() { }
    public Product(String productDescription)
    {
        this.ProductDescription = productDescription;
    }
        protected String ProductDescription;
        public Decimal Price { get; set; }
    }
 }

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            TaxableProduct t = new TaxableProduct("Toys", 100.22M);
            Console.WriteLine("Price excluding tax (" + t.getTaxRate() + "%): €" + t.Price);
            Console.WriteLine("Price including tax (" + t.getTaxRate() + "%): €" + t.getTotalPrice);
            Console.ReadKey();
        }
    }
}



输出
不含税价格(1.18%):? 100.22
含税价格(1.18%):?118.2596



Output
Price excluding tax (1.18%): ?100.22
Price including tax (1.18%): ?118.2596

推荐答案

我认为您必须指定包含欧元符号的编码.像这样的东西:
http://stackoverflow.com/Questions/7929763/how-do-i-write-special-characters-0x80-0x9f-to-the-windows-console [
I think youll would have to specify the encoding that includes the euro sign. Something like:
http://stackoverflow.com/questions/7929763/how-do-i-write-special-characters-0x80-0x9f-to-the-windows-console[^]

Console.OutputEncoding = System.Text.Encoding.UTF8;
System.Console.Out.WriteLine("œil");


这篇关于欧元符号(€)未显示在Console.WriteLine中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆