generic-list

How can I add a DisplayMember and ValueMember to a single ComboBox Item that has an assigned DataSource?

限于喜欢 提交于 2019-12-12 02:55:37
问题 I am successfully adding Display/Value pairs to a combobox like this: List<Student> BRStudents = studentsList.Where(h => h.EnrolledInAYttFM) .Where(i => i.RecommendedNextTalkTypeID.Equals(BIBLE_READING_TALK_TYPE)) .OrderBy(j => j.WeekOfLastAssignment) .ToList(); comboBoxBR.DataSource = BRStudents; comboBoxBR.DisplayMember = "FullName"; comboBoxBR.ValueMember = "StudentID"; ...but I then (in some instances) want to add another item to comboBoxBR, one which is not present in the BRStudents list

Cannot implicitly convert type 'IEnumerable<ob>' to 'Generic.List<cdsworkflows>' nested objects

拥有回忆 提交于 2019-12-11 17:49:29
问题 I have the below classes public class cdsworkflows { public string WorkflowName; public string ActionGroup; } public class cdssystems { public string cdsSystemName; public List<cdsmodules> listModules; } public class cdsmodules { public string moduleName; public List<cdsworkflows> listWorkflows; } I am pushing the values to the above Objects from a table with all these data as below. I am getting error in "select new" that: Cannot implicitly convert type System.Collections.Generic.IEnumerable

Free() pointer to Struct, inside a Struct

≯℡__Kan透↙ 提交于 2019-12-11 13:11:17
问题 I can't seem to find how to free() the sub struct. Structs: typedef struct { char ID[5]; location *loc; } observer; typedef struct { double lat; double lng; } location; My Wrapper of Free() is: void free_obs_list_node(void *data) { free(*(observer **)data); } I can free the observer struct. I cannot free the pointer to the location Struct. This is my question: how do I free the location struct pointed to by location *loc; I used a wrapper of free() as these are node's in a generic linked list

Iterate Generic List of Strings (Lync chatroom members) in Powershell

让人想犯罪 __ 提交于 2019-12-11 11:21:07
问题 I can't iterate through a Generic List of Strings in Powershell. The Object is the members of a Lync chatroom. Command to get the Generic List: $crMembers = get-csPersistentChatroom -identity "XXXX" | select members The error I receive when trying to read the Strings in the Generic List is: WARNING: An error ocurred: Cannot convert value "@{Members=System.Collections.Generic.List`1[System.String]}" to type "System.Collections.Generic.List`1[System.String]". Error: "Cannot convert the "@

Bind Directory.EnumerateFiles to a Repeater using a Generic List

自作多情 提交于 2019-12-11 10:59:07
问题 I am trying to create a small web app, that when I type in a game name, it will search through a folder with a whole lot of icons to find one similar to the typed in game. I then want to show a repeater with the name of the icon, as well as the icon next to it. So far I have successfully displayed the name with this code: IEnumerable<string> getfiles = from f in Directory.EnumerateFiles(Server.MapPath("~/_resources/game_icon"), "*.*", SearchOption.AllDirectories) where Path.GetFileName(f)

Array instead of List in WCF Service Proxy Generated using svcutil.exe

馋奶兔 提交于 2019-12-11 10:35:01
问题 I have a ServiceContract , using System.Collections.Generic; using System.ServiceModel; namespace MainModule.Sub.Communication { [ServiceContract] public interface IWebMethod { [OperationContract(IsOneWay = false)] bool InvokeAlert(List<int> userIds); [OperationContract(IsOneWay = false, Name = "InvokeAlertByMainID")] bool InvokeAlert(List<int> userIds, int mainId); [OperationContract(IsOneWay = true)] void DeletePopupNotifications(System.Data.DataSet deletedNotifications); } } I used below

ObservableCollection of open generic type

﹥>﹥吖頭↗ 提交于 2019-12-11 06:44:48
问题 I have an interface public interface IImageFilter<TIn, TOut> { // Properties TIn Input { get; set; } string Name { get; set; } Guid Guid { get; set; } TOut Process(TIn frame); } and I needed an observable collection of objects that implement the interface. private ObservableCollection<IImageFilter<T, U>> _imageFilters; the object that i pass to the collection can be IImageFilter<string, string> IImageFilter<string, int> IImageFilter<int, double> How do it declare the _imageFilters? what's the

List<T> Casting algorithms and performance considerations

时光怂恿深爱的人放手 提交于 2019-12-11 06:35:47
问题 I have the following code class Program { static void Main(string[] args) { List<A> aList = new List<A>(); var aObj = new A(); aObj.Go(aList.Cast<IB>()); } } class A : IB { public void Go(IEnumerable<IB> interfaceList) { foreach (IB ibby in interfaceList) { Console.WriteLine("Here"); } } } interface IB { void Go(IEnumerable<IB> interfaceList); } } I originally tried passing a List but that doesn't work. After a lot of help from SO I found that passing IEnumerable is the only way to get the

.SqlDataReader.ReadColumnHeader NullReferenceException

末鹿安然 提交于 2019-12-11 05:27:48
问题 This question is somewhat related to my previous one answer to which helped me to find the reason why this simple iteration thru SqlDataReader: m_aFullIDList = New Generic.List(Of Integer) While i_oDataReader.Read m_aFullIDList.Add(i_oDataReader.GetInt32(0)) End While m_iTotalNumberOfRecords = m_aFullIDList.Count does not return all the records. Turned out when Generic.List changes its Capacity to accommodate more elements (e.g from 2^19 to next one 2^20) at this point SqlDataReader simple

C# - Can you loop through types separately in a generic list?

為{幸葍}努か 提交于 2019-12-11 03:53:46
问题 I have 3 different classes, a generic "entity" class, and then two classes that inherit this, a bullet class and an enemy class. I then have a list of the entity class, with the bullets and enemies in the list, and a lot of the places I treat these the same. However, some times, I want to loop through just one of the classes, and not the other, e.g. Loop through each bullet, but not the enemies. Is there any way to do this? I tried foreach (Bullet tempBullet in entities) But I get the error