Discussion:
What does this sentence mean
(too old to reply)
Tony Johansson
2016-05-03 09:05:54 UTC
Permalink
Hello!

It's this sentence below within brackets that I have a question about.What
exactly does it mean when it says that the function takes a sequence of
string. If I pass in an array of string and then concatenate then and return
the whole string will the satisfy the sentence?

[Write a function that takes a sequence of string which it concatenates, and
returns]

//Tony
Stefan Ram
2016-05-03 14:37:59 UTC
Permalink
Post by Tony Johansson
[Write a function that takes a sequence of string which it concatenates, and
returns]
According to C# 10.14.3, a »sequence of string« might be
»IEnumerable<string>«. So maybe something like (untested):

public static string f
( global::System.Collections.Generic.IEnumerable
< string >enumerable )
{ string s = ""; foreach( var s1 in enumerable )s += s1;
return s; }

?
bradbury9
2016-05-03 20:01:57 UTC
Permalink
Post by Tony Johansson
Hello!
It's this sentence below within brackets that I have a question about.What
exactly does it mean when it says that the function takes a sequence of
string. If I pass in an array of string and then concatenate then and return
the whole string will the satisfy the sentence?
[Write a function that takes a sequence of string which it concatenates, and
returns]
//Tony
'Sequence' could be considered and array, or almost anything that implements IEnumerable imho. And yes, they ask for a function that concatenates the input strings.
Arne Vajhøj
2016-05-04 23:03:23 UTC
Permalink
Post by Tony Johansson
It's this sentence below within brackets that I have a question
about.What exactly does it mean when it says that the function takes a
sequence of string. If I pass in an array of string and then concatenate
then and return the whole string will the satisfy the sentence?
[Write a function that takes a sequence of string which it concatenates,
and returns]
That is what it would mean in general .NET context.

Unless your text book and or professor has introduced a different
terminology then that is what you should expect.

Most likely you are expected to write some sort of looping code.

If it were a real programming problem then you would not
need the function at all because:

string allstrconc = string.Join("", manystr);

should do it.

Arne

Loading...