c# Programming Glossary: mylist
C# generic list <T> how to get the type of T? [duplicate] http://stackoverflow.com/questions/1043755/c-sharp-generic-list-t-how-to-get-the-type-of-t if the property myclass.SomList is empty List myclass myList dataGenerator.getMyClasses lbxObjects.ItemsSource myList lbxObjects.SelectionChanged.. myList dataGenerator.getMyClasses lbxObjects.ItemsSource myList lbxObjects.SelectionChanged lbxObjects_SelectionChanged private..
Find an item in List by LINQ? http://stackoverflow.com/questions/1175645/find-an-item-in-list-by-linq not be what you want string search lookforme List string myList new List string string result myList.Single s s search 2 Where.. lookforme List string myList new List string string result myList.Single s s search 2 Where will return all items which match.. an IEnumerable with one element IEnumerable string results myList.Where s s search 3 First will return the first item which matches..
Properly locking a List<T> in MultiThreaded Scenarios? http://stackoverflow.com/questions/1362995/properly-locking-a-listt-in-multithreaded-scenarios public static class MyClass private static List string _myList new List string private static bool _record public static void.. static bool _record public static void StartRecording _myList.Clear _record true public static IEnumerable string StopRecording.. Only copy of the list data var result new List string _myList .AsReadOnly _myList.Clear return result public static void DoSomething..
LINQ to SQL and a running total on ordered results http://stackoverflow.com/questions/1834753/linq-to-sql-and-a-running-total-on-ordered-results question Using closures and anonymous method List Item myList FetchDataFromDatabase decimal currentTotal 0 var query myList.. FetchDataFromDatabase decimal currentTotal 0 var query myList .OrderBy i i.Date .Select i currentTotal i.Amount return..
Converting a generic list to a CSV string http://stackoverflow.com/questions/1890093/converting-a-generic-list-to-a-csv-string x x.ToString .ToArray For the general case IEnumerable T myList string csv String.Join myList.Select x x.ToString .ToArray As.. general case IEnumerable T myList string csv String.Join myList.Select x x.ToString .ToArray As you can see it's effectively..
C# - Cannot implicitly convert type List<Product> to List<IProduct> http://stackoverflow.com/questions/2640738/c-sharp-cannot-implicitly-convert-type-listproduct-to-listiproduct Get Guid companyID List contracts.IProduct myList new List dto.Product ... Any ideas why this might be happening.. to a list of another. Instead of List contracts.IProduct myList new List dto.Product You have to do this List contracts.IProduct.. dto.Product You have to do this List contracts.IProduct myList new List contracts.IProduct myList.Add new dto.Product Eric..
How do you sort a dictionary by value? http://stackoverflow.com/questions/289/how-do-you-sort-a-dictionary-by-value improve this question List KeyValuePair string string myList aDictionary.ToList myList.Sort delegate KeyValuePair string.. List KeyValuePair string string myList aDictionary.ToList myList.Sort delegate KeyValuePair string string firstPair KeyValuePair.. from vs2008 or above . List KeyValuePair string string myList aDictionary.ToList myList.Sort firstPair nextPair return firstPair.Value.CompareTo..
C# Syntax - Example of a Lambda Expression - ForEach() over Generic List http://stackoverflow.com/questions/339199/c-sharp-syntax-example-of-a-lambda-expression-foreach-over-generic-list
File System TreeView http://stackoverflow.com/questions/673931/file-system-treeview root treeView1.Nodes.Add root foreach string filePath in myList myList is your list of paths node root foreach string pathBits.. treeView1.Nodes.Add root foreach string filePath in myList myList is your list of paths node root foreach string pathBits in filePath.Split..
C# Permutation of an array of arraylists? http://stackoverflow.com/questions/710670/c-sharp-permutation-of-an-array-of-arraylists Permutation of an array of arraylists I have an ArrayList myList and I am trying to create a list of all the permutations of.. the values in the arrays. EXAMPLE all values are strings myList 0 1 5 3 9 myList 1 2 3 myList 2 93 The count of myList can be.. arrays. EXAMPLE all values are strings myList 0 1 5 3 9 myList 1 2 3 myList 2 93 The count of myList can be varied so its length..
readonly keyword does not make a List<> ReadOnly? http://stackoverflow.com/questions/10066708/readonly-keyword-does-not-make-a-list-readonly code in a public static class public static class MyList public static readonly SortedList int List myObj CharList ...etc... I can still add items to the list from another class MyList.CharList 100 new List myObj new myObj 30 30 or MyList.CharList.Add.. MyList.CharList 100 new List myObj new myObj 30 30 or MyList.CharList.Add new List myObj new myObj 30 30 Is there a way to..
How to handle add to list event? http://stackoverflow.com/questions/1299920/how-to-handle-add-to-list-event namespace test class Program class MyList T List T public event EventHandler OnAdd public void Add T.. this null base.Add item static void Main string args MyList int l new MyList int l.OnAdd new EventHandler l_OnAdd l.Add.. item static void Main string args MyList int l new MyList int l.OnAdd new EventHandler l_OnAdd l.Add 1 static void l_OnAdd..
How do C# Events work behind the scenes? http://stackoverflow.com/questions/213638/how-do-c-sharp-events-work-behind-the-scenes from somewhere else etc. A contrived example public class MyList private List string m_Strings new List string public EventHandler.. value EventArgs.Empty TestClass public class TestMyList private bool m_Fired false TestMethod public void TestEvents.. bool m_Fired false TestMethod public void TestEvents MyList tmp new MyList tmp.ElementAddedEvent new EventHandler EventArgs..
C# List<> Sort by x then y http://stackoverflow.com/questions/289010/c-sharp-list-sort-by-x-then-y class MyClass public int x public int y List MyClass MyList public void SortList MyList.Sort MySortingFunction And we have.. x public int y List MyClass MyList public void SortList MyList.Sort MySortingFunction And we have the following in the list.. you compare all members. For example public void SortList MyList.Sort delegate MyClass a MyClass b int xdiff a.x.CompareTo b.x..
How to check if a specific file exists in directory or any of its subdirectories http://stackoverflow.com/questions/3994448/how-to-check-if-a-specific-file-exists-in-directory-or-any-of-its-subdirectories overload but that seems a bit heavy handed. var MyList from f in Directory.GetFiles tempScanStorage foo.txt SearchOption.AllDirectories.. f .ToUpper .Contains foo select f foreach var x in MyList returnVal x.ToString c# subdirectories getfiles file.exists..
How to read a text file in project's root directory? http://stackoverflow.com/questions/6416564/how-to-read-a-text-file-in-projects-root-directory
How to call an async method from a getter or setter? http://stackoverflow.com/questions/6602244/how-to-call-an-async-method-from-a-getter-or-setter return await DoSomethingAsync public IEnumarable MyList get call MyAsyncMethod here c# async ctp share improve.. Make the property return a Task T public Task IEnumarable MyList get Just call the method return MyAsyncMethod Or Make the.. Or Make the property blocking public IEnumarable MyList get Block via .Result return MyAsyncMethod .Result share..
Why is List.Sort() an instance method but Array.Sort() static? http://stackoverflow.com/questions/6713932/why-is-list-sort-an-instance-method-but-array-sort-static an obvious reason. Consider the following code List int MyList new List int 5 4 3 2 1 int MyArray 5 4 3 2 1 Sort the list MyList.Sort.. new List int 5 4 3 2 1 int MyArray 5 4 3 2 1 Sort the list MyList.Sort This was an instance method Sort the Array Array.Sort MyArray..
DropDownList AppendDataBoundItems (first item to be blank and no duplicates) http://stackoverflow.com/questions/730555/dropdownlist-appenddatabounditems-first-item-to-be-blank-and-no-duplicates to the top of the list. asp DropDownList runat server ID MyList ondatabound MyListDataBound asp DropDownList Then in your code.. list. asp DropDownList runat server ID MyList ondatabound MyListDataBound asp DropDownList Then in your code behind protected.. asp DropDownList Then in your code behind protected void MyListDataBound object sender EventArgs e MyList.Items.Insert 0 new..
Scroll WPF ListBox to the SelectedItem set in code in a view model http://stackoverflow.com/questions/8827489/scroll-wpf-listbox-to-the-selecteditem-set-in-code-in-a-view-model then in your Control ListBox ItemsSource Binding Path MyList SelectedItem Binding Path MyItem Mode TwoWay SelectionMode..
How to Create a Thread-Safe Generic List? http://stackoverflow.com/questions/9995266/how-to-create-a-thread-safe-generic-list a quick wrapper that synchronizes access with a lock class MyList T private List T _list new List T private object _sync new object..
|