+ 2
How can I write x² in C# ,like done in java?
https://code.sololearn.com/cOL6NzzSDsAt/?ref=app https://code.sololearn.com/cHabR95GDe5U/?ref=app
5 Respostas
+ 2
Console.OutputEncoding = Encoding.Unicode;
What is the meaning of this line?
+ 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Main(string[] args)
{
Console.OutputEncoding = Encoding.Unicode;
Console.WriteLine("x²");
}
}
}
+ 1
From the syntax itself, it should be clear that that line is encoding some characters that couldn't be found in ASCII. Basically, it's the taking char and converting/encoding to unicode.
Why do we need encoding?
character encoding provides a key to unlock (ie. crack) the code. It is a set of mappings between the bytes in the computer and the characters in the character set. Without the key, the data looks like garbage(like in your case a question mark?)
+ 1
I'm not sure maybe Microsoft .net works differently.
Well, you can research that yourself and have fun. :)
0
So Console. OutputEncoding=Encoding.Unicode is an inbuilt method in java strings