addrange

How to specify range >2GB for HttpWebRequest in .NET 3.5

三世轮回 提交于 2019-12-01 06:58:39
问题 I'm building this class to download files in parts/sections/segments. In .NET 4.0, I can use this code to specify the range to download from long startPos = int.MaxValue+1; HttpWebRequest.AddRange(startPos); and it works because there is a long overload for the AddRange method. When I looked up the .NET 3.5 version, I realised the AddRange() method allows using int only. The possible workaround would be using the AddRange(string, int) or AddRange(string, int, int) methods. Since the class

List<T>.AddRange implementation suboptimal

梦想与她 提交于 2019-11-29 21:47:26
Profiling my C# application indicated that significant time is spent in List<T>.AddRange . Using Reflector to look at the code in this method indicated that it calls List<T>.InsertRange which is implemented as such: public void InsertRange(int index, IEnumerable<T> collection) { if (collection == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); } if (index > this._size) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_Index); } ICollection<T> is2 = collection as ICollection<T>; if (is2 != null) { int count

List<T>.AddRange implementation suboptimal

情到浓时终转凉″ 提交于 2019-11-28 17:40:08
问题 Profiling my C# application indicated that significant time is spent in List<T>.AddRange . Using Reflector to look at the code in this method indicated that it calls List<T>.InsertRange which is implemented as such: public void InsertRange(int index, IEnumerable<T> collection) { if (collection == null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.collection); } if (index > this._size) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource

ObservableCollection Doesn&#39;t support AddRange method, so I get notified for each item added, besides what about INotifyCollectionChanging?

若如初见. 提交于 2019-11-25 23:46:21
问题 I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it\'s done (i.e. collection changing besides the \'changed\'). Related Q Which .Net collection for adding multiple objects at once and getting notified? 回答1: Please refer to the updated and optimized C# 7 version. I didn't want to remove the VB.NET version so I just posted it in a separate answer. Go to updated version Seems it's not supported, I implemented by myself, FYI,