Convert List<> to Task<List<>> [duplicate] - c#

This question already has answers here:
Creating a task wrapper around an existing object
(3 answers)
Closed 2 years ago.
Is there a way to convert a list from List<> to Task<List<>> ? I know Task<List<>> to List<> but I don't know to other direction.
Thanks,

Have you tried Task.FromResult(list)? Where list is the variable storing reference to your Collection.

I think you want Task.FromResult(* your List<> here *)

Related

The difference between List<MyClass> and MyClass[] [duplicate]

This question already has answers here:
Array versus List<T>: When to use which?
(16 answers)
Closed 7 years ago.
What is the difference between List<MyClass> and MyClass[] in C#.
Thanks
MyClass[] is an array, and once set in size it can't grow.
A List<MyClass>, however, can have things constantly added to it.

Check a list has set of values [duplicate]

This question already has answers here:
Determine if a sequence contains all elements of another sequence using Linq [duplicate]
(4 answers)
Closed 8 years ago.
I have two sting lists
List<string> list1=new List(){"1","2","3"};
List<string> list2=new List(){"1","2"};
What will be the easiest way to check if list1 contains the values in list2.
How about
list1.Except(list2).Any();
Try using
[listName].Except(SecondListName).Any();
This should work.

How to use array in two different forms? [duplicate]

This question already has answers here:
How to share data between forms?
(2 answers)
Closed 8 years ago.
I'm trying to use one array that I declared in one form, to plot a graph with zedgraph, in a different form.
How do I need to declare the array and where?
Short answer: Don't declare your array in the first form.
Declare it in a separate component/class/whatever instead, and let both forms access the array there. That way, the array should be independent of the forms, and both can use it.

Converting Array Type in C# [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Convert string[] to int[] in one string of code using LINQ
I have an array of strings I want to convert it to array of int
is there any way to convert it directly without looping
I mean without use foreach, for , LINQ select statement, etc.
Any suggestion please.
Array.ConvertAll: http://msdn.microsoft.com/en-us/library/exc45z53.aspx

Make list immutable [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Immutable List in C#
Is it possible to make a list immutable
You can use ReadOnlyCollection<T> instead.
List<T>.AsReadOnly() returns a readonly wrapper, so that you can't add/remove/replace elements.
To be truly immutable, the type T must be an immutable Type.

Categories