Where could I find code of a C# equivalence of Python maketrans and translate?
Thanks!
Where could I find code of a C# equivalence of Python maketrans and translate?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This should take you most of the way there:
You’re responsible for making sure that intab and outtab are the same length. You can add functionality for dropping letters, etc.
The dictionary construction is done in a cool LINQ-y way. It’s a bit non-obvious, so the commented out code is provided and does the same thing.
Here’s how it looks in python (example lifted from here):
Here is C# test code:
And here is the output: