M
M
Mister_krid2022-04-07 13:14:28
C++ / C#
Mister_krid, 2022-04-07 13:14:28

Why do you need to use long when interpolating?

When formatting an array of numbers into a phone number, ToString() only works with long.Parse. Why? We get a string when using Concat, why doesn't he like it?

private string CreatePhoneNumber(int[] number)
        {
            return long.Parse(string.Concat(number)).ToString("(000) 000-0000");
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2022-04-07
@Mister_krid

Because your number with 9XX-* doesn't fit into int32 space

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question