mrbitzilla
mrbitzilla

Reputation: 398

Java Collections.singletonList(object) C# equivalent

What would be the C# equivalent to the following:

Java:

String data = "dataString";
Collections.singletonList(data);

Specifically for the Collections.singleton(object) function. Thanks in advance.

Collections.singletonList documentation description:

Returns an immutable list containing only the specified object. The returned list is serializable.

Upvotes: 0

Views: 315

Answers (1)

Amit Patil
Amit Patil

Reputation: 57

This may solve your purpose.

var lst = Enumerable.Repeat(data,1);

Upvotes: 1

Related Questions