Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to add a list to observablecollection in c#

var stringList = new List<string>() {"1","2","3"};
//Use the contructor override to add the list to the new collection
var obStrings = new ObservableCollection<string>(stringList);

//If you already have a collection. Store that into a tempory list, 
//add the new range to the tempory list. Then same as above
var ob2list = obStrings.ToList();
ob2list.AddRange(stringList);
obStrings = new System.Collections.ObjectModel.ObservableCollection<string>(ob2list);
Comment

c# list to observablecollection

var lstNames = new List<string>() {"Harry", "Brandin"};
var obNames = new ObservableCollection<string>(lstNames);
Comment

PREVIOUS NEXT
Code Example
Csharp :: hash password with salt c# 
Csharp :: c# postmessage mouse click 
Csharp :: C# .NET Core linq Distinct 
Csharp :: unity instantiate with name 
Csharp :: google sheets sum if check contains string 
Csharp :: excute bash and other linux scripts from c# 
Csharp :: rb.addforce c# 
Csharp :: instantiate iqueryable c# 
Csharp :: unity smooth rotation 2d 
Csharp :: unity waituntil coroutine 
Csharp :: C# .net core convert to int round up 
Csharp :: call function from another script unity 
Csharp :: initialize ConsoleLoggerProvider in EF core 
Csharp :: round float c# 
Csharp :: c# difference between two dates in milliseconds C# 
Csharp :: convert string to date in c# 
Csharp :: all month in array 
Csharp :: if statement swiftui 
Csharp :: unity new input system keydown 
Csharp :: c# foreach dictionary 
Csharp :: unity topdown 
Csharp :: c# integer to bit string 
Csharp :: unity cos 
Csharp :: c# current dir 
Csharp :: send type as argument c# 
Csharp :: string reverse c# 
Csharp :: if in dictionary c# 
Csharp :: how to remove vowels from a sttring using regex c# 
Csharp :: asp.net file detect mime type 
Csharp :: order by length descending C# 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =