O
O
okalash2019-05-16 01:08:25
.NET
okalash, 2019-05-16 01:08:25

What should be the input parameter of a C# method?

There is a task "signal decoding", but that's bad luck.
Most of the input parameters are clear, but there is one that does not lend itself to me (highlighted):
Decode(0));
decode(123);
decode(1.23);
Decode(1...2..3);
What do I need to specify as the input parameter of the method?
Thanks in advance!
5cdc939cca6c8713896859.jpeg5cdc93a2a0500276075060.jpeg
Exercise :
5cdd32a36dc4b913905876.png

Answer the question

In order to leave comments, you need to log in

6 answer(s)
#
#, 2019-05-16
@okalash

1 - the originals are not visible - is this definitely C#?
2 - what? suddenly Mono?
3 - if this is a test for a vacancy - perhaps there is a check for readiness for other people's mistakes - "1 ... 2..3" for example?

then the solution is simple
using System;
using System.Linq;

namespace do_something_I_don_t_know_what
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Decode("1...2..3"));
        }

        static string Decode(object a)
        {
            return new string (
                (a as string)
                .ToCharArray()
                .Where(c => char.IsDigit(c))
                .ToArray()
                );
        }
    }
}
you can come up with something else ad infinitum .. but in my opinion it makes no sense

V
Vladimir S, 2019-05-16
@hePPer

apparently it needs a range from version 8
ranges

B
BasiC2k, 2019-05-16
@BasiC2k

It looks like the input data is of different types. The latter is most likely string.

S
samthet, 2019-05-16
@samthet

Should be . There are 2 dots everywhere, this is the Range type, it has not yet been added to the language and is still being tested, you need to check the "preview" flag in the project settings, where the language version is indicated. Most likely, a simple call to IntelliSense via "ctrl +." and viduha will do everything for you (perhaps) Just out of interest, who gives such tasks at all? Where are they from? And for the future, before writing to the forums - read the errors, in them in 99% of cases the answer. Decode(1..2..3);

E
eRKa, 2019-05-16
@kttotto

Perhaps you need to remove everything that is not a number or all the points and you get "123"

D
dvz2010, 2019-05-16
@dvz2010

It looks like going beyond the limit of the bit grid for a 10-bit number. Leave only numbers. Convert to integer and make & 1023

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question