草庐IT

TASK_LIST_GRID

全部标签

c# - List<T> 没有实现 SyncRoot!

每个人都使用很多列表。我需要遍历这个列表,所以我使用已知的SyncRoot模式。最近我注意到this发布应该避免使用SyncRoot以支持“嵌入式”线程安全(每个方法将锁定一个私有(private)对象而不使用SyncRoot属性公开它)。我能理解,部分同意。问题是List类不实现SyncRoot属性,即使实现了ICollection接口(interface),它公开了SyncRoot属性。我说这会破坏代码Listlist=newList()list.SyncRoot;给我以下编译器错误:errorCS0117:'System.Collections.Generic.List'does

c# - 编辑 List<Tuple> 项

用List你可以用这个简单地编辑一个项目:varindex=List.FindIndex(s=>s.Number==box.Text);List[index]=newString;但是,如何将它应用于List>例如? 最佳答案 您可以用类似的方式找到索引-通过对列表中的每个元组应用条件:varindex=listOfTuples.FindIndex(t=>t.Item1==box1.Text||t.Item2==box2.Text);您可以通过调用Tuple.Create来替换一个项目:listOfTuples[index]=Tup

c# - 如何使用 Task.Run(Action<T>)

我正在尝试创建一个接受TcpClient连接并在客户端连接后执行任务“ConnectedAction”的方法。我在尝试创建新任务以运行委托(delegate)“ConnectedAction”时收到编译错误。Argument1:cannotconvertfrom'void'to'System.Func'我相信这个错误是因为该方法正在尝试运行“ConnectedAction”方法并将void返回给Task.Run参数。如何让任务运行“ConnectedAction”委托(delegate)?classListener{publicIPEndPointListenerEndPoint{ge

c# - C# : generate a list of two dimension arrays with the same shape 中的 FsCheck

假设我正在编写一些视频分析代码。这是视频类的简化版本:publicclassVideo{publicreadonlyintWidth;publicreadonlyintHeight;publicreadonlyListFrames;publicVideo(intwidth,intheight,IEnumerableframes){Width=width;Height=height;Frames=newList();foreach(varframeinframes){if(frame.GetLength(0)!=height||frame.GetLength(1)!=width){thr

c# - ActionResult<IEnumerable<T>> 必须返回一个 List<T>

使用ASP.NETCore2.1获取以下代码:[HttpGet("/unresolved")]publicasyncTask>>GetUnresolvedIdentities(){varresults=await_identities.GetUnresolvedIdentities().ConfigureAwait(false);returnresults.ToList();}自从GetUnresolvedIdentities()我就想到了返回IEnumerable我可以返回returnawait_identities.GetUnresolvedIdentities().Configu

c# - AllowUserToAddRows 不适用于 DataGridView 上的 List<> 数据源

我有一个DataGridView与DataSource设置为List但是,当我设置AllowUserToAddRows时,新行指示器不显示至true,当我设置DataSource至BindingList,这似乎解决了问题。问:应该替换我的List与BindingList或者有更好的解决方案? 最佳答案 是否myClass有一个公共(public)的无参数构造函数?如果不是,您可以从BindingList派生并覆盖AddNewCore调用您的自定义构造函数。(edit)或者-只需将您的列表包装在BindingSource中它可能会起作

c# - KendoUI Grid InCell 编辑中的异常需要批量更新,批量设置为 false

我在尝试将KendoUI网格用于在VisualStudio2013中开发的ASP.NETMVC(.net4.5)应用程序时出现异常。我已将网格配置为使用内联编辑,并将Batch显式设置为false在数据源部分。这被呈现为局部View。需要注意的是,如果GridEditMode.InLine设置为GridEditMode.InCell,则不会抛出异常。异常YoumustuseInCelleditmodeforbatchupdates.Description:Anunhandledexceptionoccurredduringtheexecutionofthecurrentwebreque

c# - 我可以将 Task.Delay 用作计时器吗?

我想每秒执行一些代码。我现在使用的代码是:Task.Run((Action)ExecuteSomething);ExecuteSomething()定义如下:privatevoidExecuteSomething(){Task.Delay(1000).ContinueWith(t=>{//Dosomething.ExecuteSomething();});}这个方法会阻塞线程吗?或者我应该在C#中使用Timer类吗?似乎Timeralsodedicatesaseparatethreadforexecution(?) 最佳答案 Tas

c# - 正确公开 List<T>?

我知道我不应该公开List在一个属性中,但我想知道正确的方法是什么?例如,这样做:publicstaticclassClass1{privatereadonlystaticList_list;publicstaticIEnumerableList{get{return_list;//return_list.AsEnumerable();behavesthesame}}staticClass1(){_list=newList();_list.Add("One");_list.Add("Two");_list.Add("Three");}}将允许我的调用者简单地转换回List:privat

c# - 将 BindingList<MyObject> 转换为 List<MyObject> c#

如何将BindingList转换为List? 最佳答案 试试这个Listlist=yourBindingList.ToList();int是你的类型=) 关于c#-将BindingList转换为Listc#,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/10204554/