Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a C# equivalent of Pythons chr and ord?

Tags:

python

c#

char

I'm currently learning C# and was wondering if C# has an equivalent to chr and ord.

like image 679
Mahogany Avatar asked Feb 28 '19 14:02

Mahogany


People also ask

Why does AC have a slash?

Why is there a slash between A and C in A/C? AC is used as an abbreviation for alternating current and A/C for air conditioning. For most people AC is used for alternating current because it was the first use of this abbreviation and A/C is used for air conditioning to differentiate from alternating current.

Why is it called AC?

He combined moisture with ventilation to "condition" and change the air in the factories, controlling the humidity so necessary in textile plants. Willis Carrier adopted the term and incorporated it into the name of his company. Domestic air conditioning soon took off.

Which is correct AC or AC?

Senior Member. A/C unit (air conditioning unit) is a single machine. (e.g. What's that ugly box on your wall? - It's the air conditioning unit.) A/C (air conditioning) is the entire system, or the result it gives.

What is AC?

What A/C Means. The term “A/C” stands for “air conditioning,” but it's frequently used to describe any type of home cooling equipment, such as a traditional split-system air conditioner or heat pump, mini-split unit, geothermal system, or even a window unit.


1 Answers

In C#, char is efficiently UInt16; that's why we can simply cast:

chr: (char) explicit cast (if i is out of [0..UInt16.MaxValue] range we'll have integer overflow)

 int i = ...
 char c = (char) i; 

ord: either (int) or even implicit cast (cast from char to int is always possible)

 char c = ...
 int i = c;
like image 194
Dmitry Bychenko Avatar answered Oct 18 '22 20:10

Dmitry Bychenko