text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : There probably is a question on this already , but I was n't able to come up with the search terms to find an answer..I 'm probably missing something obvious here , but why am I not allowed to do the following , which gives the error : `` Argument 1 : can not convert from System.Collections.Generic.IEnumerabl... | Constraint on generic type can not be used in IEnumerable ? |
C_sharp : I 've been reading a lot about why constructors are useful and all the resources I found specify that constructors are used to initialize the instances of your classes . A key benefit of using a constructor is that it guarantees that the object will go through proper initialization before being used , often a... | Constructors in C # |
C_sharp : I am iterating over elements which were taken from HTML . structureElement seems to hold found element , but when I run .FindElement ( ) on it , it returns always value from first iteration . Why is that ? Here is my code : <code> IReadOnlyCollection < IWebElement > structureElements = driver.FindElements ( B... | FindElement doesnt iterate when iterating elements in IReadOnlyCollection |
C_sharp : How do I declare and use generic interfaces ( see namespace Sample2 ) to work in the same way as with classes in namespace Sample1 ? I know there is a workaround ( see namespace Sample2Modified ) but that is not what I 'm trying to achieve.Works with classesWhen using classes , this works fine : Does not work... | How to use a generic type parameter as type parameter for a property declared as an interface with type constraints ? |
C_sharp : I 'm a relative newbie to C # , although I am a competent programmer , and I confess that I am totally confused as to whether or not it is a good idea to write custom collection classes . So many people seem to say `` do n't '' , yet there is a whole set of base classes for it in C # .Here is my specific case... | C # Collection classes - yes or no |
C_sharp : I am using the new JsonSerializer from NETCore 3.0 's System.Text.Json namespace to deserialize Json documents like this : Response is defined as : The fact that JsonDocument implements IDisposable makes me wonder if by keeping a reference to an element ( Bar ) that can be contained in a JsonDocument , will c... | Am I creating a leak here ? |
C_sharp : I just lifted this snippet from a website and it proved to be exactly the solution I needed for my particular problem . I have no idea what it is ( particularly the delegate and return parts ) and the source does n't explain it . Hoping SO can enlighten me . <code> myList.Sort ( delegate ( KeyValuePair < Stri... | ok , this worked . what is it exactly ? |
C_sharp : In C # ( .NET 4.5 ) I would like to subscribe to an event while I 'm creating an object.The following , of course , would work : But want to find out if it 's possible to do something along the lines of : Post-discussion edit : This is in order to accomplish is something like : <code> CheckBox c = new CheckBo... | Subscribing to event while creating object in C # |
C_sharp : Given an Enumerable , I want to Take ( ) all of the elements up to and including a terminator ( throwing an exception if the terminator is not found ) . Something like : ..except not crappy . Only want to walk it once.Is this concisely possible with current operators in .NET 4 and Rx or do I need to write a n... | Looking for a particular Enumerable operator sequence : TakeWhile ( ! ) + Concat Single |
C_sharp : I did this pattern to match nested divs : This works nicely , as you can see in regex101.However , when I write the code below in C # : It throws me an error : As you can see \g does n't work in c # . How can I match the first subpattern then ? <code> ( < div [ ^ > ] * > ( ? : \g < 1 > | . ) * ? < \/div > ) R... | How can I match the first subpattern in C # ? |
C_sharp : There are type parameters for methods . Why there are no type parameters for constructors ? ExampleI think there are several ( not many ) examples where it would be usefull . My current problem was following : A Delegate is enough for my class . But to pass it as method group I need to define the parameter as... | Why are type parameters not allowed in constructors ? |
C_sharp : This question is probably language-agnostic , but I 'll focus on the specified languages.While working with some legacy code , I often saw examples of the functions , which ( to my mind , obviously ) are doing too much work inside them . I 'm talking not about 5000 LoC monsters , but about functions , which i... | General function question ( C++ / Java / C # ) |
C_sharp : I want a regex pattern to find any integer in the string , but not float ( with decimal point as `` . '' or `` , '' . So for string : abc111.222dfg333hfg44.55it should only find:333I created regex pattern : but it fails when using in C++ STL regex . It throws exception : but it works nice in C # Regex classUP... | regex : find integer but not float |
C_sharp : I am working on a multi-touch app using Monogame , where multiple users can work on a larger multi-touch screen with separate documents/images/videos simultaneously , and I was wondering if it 's possible to make gestures `` context-aware '' , i.e . two fingers pinching a document on one side of the wall shou... | Is it possible to get `` contextual '' gestures in Monogame/XNA ? |
C_sharp : I just do n't get something in the .NET generic type casting.Can someone explain what happens in the following code snippet ? <code> void Main ( ) { IEnumerable < int > ints = new List < int > ( ) ; IEnumerable < string > strings = new List < string > ( ) ; var rez1= ( IEnumerable < object > ) ints ; //runtim... | Generics type casting |
C_sharp : Can someone explain to me why the below code outputs what it does ? Why is T a String in the first one , not an Int32 , and why is it the opposite case in the next output ? This puzzle is from an interview with Eric LippertWhen I look through the code , I really have no idea if it 's going to be an Int32 or a... | Puzzle from an Interview with Eric Lippert : Inheritance and Generic Type Setting |
C_sharp : I have a List < string > myList in my class that I want to be readonly for the class users.Like this I thought I could set the myList value inside my class in my private members and make it readonly for the class users . But I realised that declaring it that way I 'm unable to set any value . <code> List < st... | How to make a readonly C # List by non declaring its set attribute |
C_sharp : I have a Flags Enum : and then a classAssuming the following values and a specific range period : How can substract from the totalSeconds the task 's totalSeconds ? So basically I want to exclude from the totalSeconds the period when the task occures which is every Monday , Tuesday , Wednesday between 00:00 a... | c # DateTime range exclude specific ranges |
C_sharp : I 'm allowing users to input their own SQL statement to execute , but only if it 's a SELECT statement . Is there a way to detect if the SQL statement is anything but this , i.e . an ALTER , INSERT , DROP , etc. ? I 'll worry about other concerns such as a query locking up a table and such later , but this is... | Prevent Non-SELECT SQL Statements |
C_sharp : Is it possible to add dates in C # ? I tried this but it does n't work . <code> ( DateTime.Today.ToLongDateString ( ) + 10 ) | Adding DateTime in C # |
C_sharp : I have a WPF program , and when I localize it , it fails . I created this XML namespace , which corresponds to the file location , in the Window element : This is how I am localizing each element : The designer works perfectly fine , and I when I choose Resources. , auto-complete pulls up the available items ... | Why ca n't I localize my WPF program ? I get `` Exception thrown : 'System.Windows.Markup.XamlParseException ' in PresentationFramework.dll '' |
C_sharp : I recently started learning c # and learned that there are 2 ways to have my code output even numbers when I write this For loop . I learned the syntax of version 2 , which is intuitive to me . However , version 1 was an exampled I found elsewhere online . I want to understand if there is a difference between... | What is the more efficient syntax to produce an even number in my console project ? |
C_sharp : While perusing Twitter I spotted a tweet by a Game Developer I follow that just said ; @ ChevyRay 2:44 AM - 5 Jul 2016 i give you : the stupidest 8 lines of code i ’ ve ever written that is actually used by my game ’ s code Immediately I looked at it and thought to myself what does this do ? I 'm sure the pos... | What is the purpose of Yield and how does it work ? |
C_sharp : I 'm creating a query string in a web form , and I 'm dealing with values from the parameters that might be null . There are lots of ways to check and fix these , but the most elegant one I found is the following : The only issue is ... it does n't work . When the code reaches this part , the string stops ass... | Why is the null coalescing operator breaking my string assignment in c # ? |
C_sharp : What is the difference betweenandThey seem to give me the same results . <code> var q_nojoin = from o in one from t in two where o.SomeProperty == t.SomeProperty select new { o , t } ; var q_join = from o in one join t in two on o.SomeProperty equals t.SomeProperty select new { o , t } ; | What is the difference between where and join ? |
C_sharp : I 'm trying the PagedList.Mvc library from herehttps : //github.com/TroyGoode/PagedListwhich has this usage sampletypical implmentations of MyProductDataSource.FindAllProducts ( ) ; are along the lines ofwhich of course has the InvalidOperationException ( ) and DBContext is already disposed messageLooking for... | How to return IQueryable < T > for further querying |
C_sharp : My questions as follows , I need to check conditions through the database . which means in the simple application we check if conditions like this.Suppose , Client , needs to change the condition dynamically , which means he need to add additional condition to the system like , if 31 < = age & & age < = 40 = ... | How to check if statements dynamically |
C_sharp : Newtonsoft.Json.Linq.JObject implemented IEnumerable < T > , and not explicit implementation , but why ca n't do this : WHY ? Thanks . <code> using System.Linq ; ... var jobj = new JObject ( ) ; var xxx = jobj.Select ( x = > x ) ; //errorforeach ( var x in jobj ) { } //no error | Why ca n't use LINQ methods on JObject ? |
C_sharp : I 've got code in a button click like so : Nowhere else but in the finally block is the cursor set back to default , yet it does `` get tired '' and revert to its default state for some reason . Why would this be , and how can I assure that it will not stop `` waiting '' until the big daddy of all the process... | Why would the hourglass ( WaitCursor ) stop spinning ? |
C_sharp : I write simple library wich returns List of names.But , what i should returns if i can not find anything ? or example : This code can be used from another components and i do not want to corrupted it.If i return null- i think it is right way to check it . But , may be i should return empty list ? Thank you . ... | What result i should return ? |
C_sharp : I have the following class : In English grammar you can ’ t have “ is something equal to something ” or “ does something greater than something ” so I don ’ t want Is.EqualTo and Does.GreaterThan to be possible . Is there any way to restrict it ? Thank you ! <code> public class Fluently { public Fluently Is (... | Question regarding fluent interface in C # |
C_sharp : I would like to print products in order of quantity.The product with a bigger total should be first.What am I missing here as it 's NOT printing in order or total <code> class Program { static void Main ( ) { var products=new List < Product > { new Product { Name = `` Apple '' , Total = 5 } , new Product { Na... | How do you order by Greatest number in linq |
C_sharp : I am cross-posting this question from Microsoft Community because I have n't gotten any response there , and maybe someone here can shed some light on this.I have noticed an issue that is specific to Word 2013 when using VSTO to process a document.The document contains an image in the header or footer that ha... | BUG : Word 2013 VSTO Can not Handle Image in Header Formatted Behind or In Front of Text |
C_sharp : I want to replace every occurrence of one of those magic 2-byte packages in my List < byte > with a single byte : { 0xF8 , 0x00 } - > Replace with 0xF8 { 0xF8 , 0x01 } - > Replace with 0xFB { 0xF8 , 0x02 } - > Replace with 0xFD { 0xF8 , 0x03 } - > Replace with 0xFEFor example : This is my solution so far , wh... | Replace two bytes in a generic list |
C_sharp : I have a C # application that uses an unmanaged C++ DLL . I 've found a crash that only happens in WinXP ( not Win7 ) when the memory I 'm passing back from the C++ DLL is too big.The basic flow is that C # starts an operation in the C++ DLL by calling a start function , in which it provides a callback . The ... | What 's the memory limit in WinXP when getting a callback from a C++ DLL in C # ? |
C_sharp : The issue is that VS2010 Code Analysis is returning two CA2000 warnings for a particular function . I have n't been successful at reproducing the warnings with a smaller block of code , so I 've posted the original function in it 's entirety.The two CA2000 warnings pertain to the using statements containing t... | CA2000 Warning That Can Be Removed By Commenting out Seemingly Unrelated Code |
C_sharp : Do I have to wrap all my IDisposable objects in using ( ) { } statements , even if I 'm just passing one to another ? For example , in the following method : Could I consolidate this to just one using like this : Can I count on both the Stream and the StreamReader being disposed ? Or do I have to use two usin... | Is it necessary to nest usings with IDisposable objects ? |
C_sharp : I 'm trying to create a Dynamic Data website which should allow an administrator to directly edit the data in most tables in a database.So far , I have an EDMX and POCO classes , all attached to an Interface used to apply the DataAnnotations on the fields.I want to have an editable grid for each table , so I ... | `` The ORDER BY sort key ( s ) type must be order-comparable '' with dynamic data |
C_sharp : I have this code that emits some IL instructions that calls string.IndexOf on a null object : This is the generated IL code : As you can see there are three nop instructions before the call instruction.First I thought about Debug/Release build but this is not compiler generated code , I am emitting raw IL cod... | Why is IL.Emit method adding additional nop instructions ? |
C_sharp : Consider a class like this : How do I make the following code work ? Now I get this exception : InvalidCastException : Unable to cast object of type 'MyString ' to type 'System.String ' . <code> public class MyString { private string _string ; public string String { get { return _string ; } set { _string = va... | String cast not working |
C_sharp : This is weird ... done updates loads of times before but can not spot why this is different.although I am using .net 4.0 now - however i doubt its a bug in its L2S implementation . Its not like this is a wierd and wonderful application of it . Although i am fairly sure this code worked whilst i was using the ... | Linq2Sql - attempting to update but the Set statement in sql is empty |
C_sharp : I 'm working with a MongoDB database . I know when you insert a DateTime into Mongo , it converts it to UTC . But I 'm making a unit test , and my Assert is failing.I must be missing something obvious . When I look in the debugger , I can see that the datetime 's match , but the assert still says they do not ... | DateTime ToLocalTime failing |
C_sharp : I asked a question and got answered here about performance issues which I had a with a large collection of data . ( created with linq ) ok , let 's leave it aside.But one of the interesting ( and geniusly ) optimization - suggested by Marc - was to Batchify the linq query . Here , the purpose of Batchify is t... | Batchify long Linq operations ? |
C_sharp : I was excited to create my first app with C # 5.0 , and I wanted to use the async/await keywords to ease the pains of async data calls.I 'm a bit baffled that interfaces does not allow the async keyword to be part of the contract , as the await keyword only works for async marked methods . This would mean tha... | Does the lack of the async keyword in interfaces break DI in C # 5.0 ? |
C_sharp : Let 's say that I have a class ( ClassA ) containing one method which calls the constructor of another class , like this : The class ClassB looks like this : ... and ClassC is even more simple : If I put these classes in their own assembly and compile the whole solution I do n't get any errors . But if I repl... | Why am I forced to reference types in unused constructors ? |
C_sharp : I have an instance variable with several members , many of which have their own members and so on . Using the debugger and watch variables , I found a string variable with a specific value that I need by diving into this variable 's members.However , after spending some time on other things and coming back to... | Find a variable with a given value in VS2008 |
C_sharp : For the following code : The result is B.G ( ) , whereas the result of similar C++ code would be D.G ( ) .Why is there this difference ? <code> class B { public String G ( ) { return `` B.G ( ) '' ; } } class D : B { public String G ( ) { return `` D.G ( ) '' ; } } class TestCompile { private static String Te... | Why does this generic method call the base class method , not the derived class method ? |
C_sharp : For example , is there anything wrong with something like this ? If it were just a simple integer variable declaration it would be fine because once it went out of scope and would later be collected by the garbage collector but events are a bit .. longer-living ? Do I have to manually unsubscribe or take any ... | Anything wrong with short-lived event handlers ? |
C_sharp : I have a map-tile setting I 'm updating through a menu-button . I 've got an odd situation where I was only hitting an error on release builds . Code is as follows : View-ModelViewThis was all working fine in my developer environment but when I generated a release build I was getting the following : ErrorSyst... | Private setter throwing error only on release build |
C_sharp : I need to make my mutable class immutable , now it looks like as following . However , still I 'm not sure that I have a fully `` immutable* class , and if it is , what kind of immutability this is called ? Based on my application B needs to be changed from time to time ; hence to keep the property of immutab... | Can I call this C # class `` immutable '' ? |
C_sharp : What I am trying to do is load in objects from an XML save file . The problem is those objects are configurable by the user at runtime , meaning i had to use reflection to get the names and attributes of those objects stored in an XML file.I am in the middle of a recursive loop through the XML and up to the p... | Generically creating objects in C # |
C_sharp : I am running the following program on two different machines : On one machine , with .NET 4.5 and Visual Studio 2012 installed this prints `` true '' , on another one , with .NET Framework 4.6.2 and Visual Studio 2015 it prints `` false '' .I thought that anonymous methods were static if they are defined in a... | Anonymous method in static class is non-static ? How to invoke it ? |
C_sharp : I want to convert a DateTime ? to string . If a date is null then return `` '' , else return a string format like this : `` 2020-03-05T07:52:59.665Z '' . The code is something like this but it wo n't work . It said `` DateTime ? '' do not contain a definition for `` ToUniversalTime '' . Someone know how to fi... | Convert DateTime ? to string |
C_sharp : Just for fun I built a quicksort implementation in C # with Linq : It sorts 10000 random integers in about 13 seconds.Changing it to use int [ ] instead of List results in about 700 times better performance ! It only takes 21ms to sort the same 10000 random integers . Just looking at the code I would have ass... | Quicksort with Linq performance Advantage passing T [ ] vs. IEnumerable < T > |
C_sharp : We have several modules in our software that ship as a single product . When a module is activated , those features become available . We would like our OData APIs to follow the same pattern . However I ca n't figure out how to make the $ metadata ignore controllers for modules that have been disabled . Basic... | Disabling OData V4 meta data and controllers at runtime |
C_sharp : The following short but complete example programwith T replaced by the following typesyields the following interesting results on my machine ( Windows 7 .NET 4.5 32-bit ) Question 1 : Why is ComplexClass so much slower than SimpleClass ? The elapsed time seems to increase linearly with the number of fields in... | Field access through array is slower for types with more fields |
C_sharp : I 'm working with an external library that has an enum . There are some members of this enum that , when you call ToString ( ) on them , return the name of a different member of the enum.I know that when two enum members have the same numerical value , you can get behavior like this , but I know , from decomp... | Why does Enum.ToString ( ) not return the correct enum name ? |
C_sharp : Let 's say I have an interface like that : Is there any way to implement the DoSomething method with type constraint ? Obviously , this wo n't work : This obviously wo n't work because this DoSomething ( ) wo n't fully satisfy the contract of IAwesome - it only work for a subset of all possible values of the ... | Type constraints on implementations of generic members of non-generic interfaces in C # |
C_sharp : I 'm working on project in which I 'm Posting data from asp.net webform to WCF service . I 'm posting data through params and the service respond me back a JSON string . Now I have an issue in deserialize . I read many threads but did n't find any solution . Hope someone can sort out my problem . Thanks in Ad... | How to Deserialize JSON |
C_sharp : I found with or without flags attributes , I can do bit operation if I defined the following enumI am wondering why we need flags attribute ? <code> enum TestType { None = 0x0 , Type1 = 0x1 , Type2 = 0x2 } | Is flags attribute necessary ? |
C_sharp : I have a generic class A < T > , that implements IEnumerable < T [ ] > .I want to have a convenience wrapper B that inherits from A < char > and implements IEnumerable < string > .Now , this works perfectly fine , foreach variable type is inferred to be string : But this wo n't compile , saying `` The type ar... | Multiple IEnumerable implementations paradox |
C_sharp : I just established a connection to SWI Prolog and want to manipulate facts . e.g . retract and assert them.I have some function like this : As you can see this function , it 's working for assertion as expected , but not for retract . The matter is that , I want to delete all tablets facts ( they are dynamic ... | Prolog C # Interface retract from file |
C_sharp : I 'm trying to hold in memory a collection of references of type Action < T > where T is variable type I 've found a solution with dynamic but I would prefer not to use dynamic the solutionDoes anyone know a better approach to handling this ? Thanks in advance . <code> public class MessageSubscriptor : IMessa... | Storing Action < T > in a single collection for later usage |
C_sharp : This is extremely slow : This is about 5x faster : Can anybody tell me why ? <code> try { x = k / y ; } catch ( DivideByZeroException ) { } if ( y > 0 ) x = k / y ; | DivideByZeroException too slow |
C_sharp : I have to query collection like this : s.CountryCode above is an example . I want to make it variable and call for different columns , like this : So I would like to define function where the column expression is a parameter . What is the signature of such function ? myList is an ObservableCollection , and my... | linq expression as parameter |
C_sharp : I have a marker interface something like this : And i want to apply it to methods on different classes in different assemblies ... Then I want to Get a MethodInfo for all methods that have this attribute applied . I need to search the whole AppDomain and get a reference to all these methods . I know we can ge... | Is there a quicker/better way to get Methods that have attribute applied in C # |
C_sharp : Put default ( T ) in an interface . Explicitly implement the interface . The result does not compileI fully expect default ( ConcreteWhatever ) . What I get is default ( T ) which results in a compilation error . I just go in and replace default ( T ) with null and things are fine . But this is hideous . Why ... | C # - How are we supposed to implement default ( T ) in Interfaces ? |
C_sharp : A bit of a conceptual question : I 'm creating my custom structure , in the vein of a Vector3 ( 3 int values ) and I was working through overloading the standard operators ( + , - , * , / , == etc ... ) As I 'm building a library for external use , I 'm attempting to conform to FxCop rules . As such , they re... | Operator Overloading in C # - Where should the actual code code go ? |
C_sharp : Here is a simplified function that I want to create : In that code block , I get the compiler error : Error CS0029 Can not implicitly convert type 'System.Collections.Generic.List < > ' to 'System.Collections.Generic.List'In the documentation for Anonymous types , it says that anonymous types are treated as t... | Why does n't IEnumerable of anonymous types return a List < object > on ToList ( ) ? |
C_sharp : I know I ca n't overload a return type ( I think I know this ) ... produces error already defines a member called ' F ' with the same parameter typesHowever , I 'm reading the documentation for ISet from MSDN , and I think I see the two Add methods that only vary by return type.What is going on here ? <code> ... | How does ISet have two Add ( T item ) methods that vary only by return type ? |
C_sharp : I am trying to use the following custom task scheduler to limit concurrent web requests : I 'm using it like this : The problem is that the inner tasks are using my LimitedConcurrencyLevelTaskScheduler instead of the default TaskScheduler . This leads to self blocking and the output is like this : When I chan... | TaskScheduler with limited concurrency blocks itself |
C_sharp : I am trying to format some precise dates , converting them from a Unix timestamp to a DateTime object . I noticed that the AddSeconds method has an overload that accepts a floating point number.My expectation is that I may pass in a number such as 1413459415.93417 and it will give me a DateTime object with ti... | Is .NET DateTime truncating my seconds ? |
C_sharp : I have two questions : 1 ) What is the fastest algorithm to put this list in a `` connecting '' order ? 2 ) Is this an existing problem/algorithm , and what name does it have ? The nodes are always connected in a circular fashion , so my starting ID does not matter . Given this list : node1 & node2 are not in... | Fastest algorithm for a 'circular linked list builder ' |
C_sharp : I want to upload a file ( VideoFile ) to server through BackgroundTransferService.My problem is , I also want to send 2 parameters along with File ( POST request ) .So , is it possible to send parameters along with File upload while using BackgroundTransferService API.. ? Code with BackgroundTransferService :... | BackgroundTransferService with POST method and Parameters |
C_sharp : So here 's what I 'm looking to achieve . I would like to give my users a single google-like textbox where they can type their queries . And I would like them to be able to express semi-natural language such asit 's ok if the syntax has to be fairly structured and limited to this specific domain ... these are... | Parsing a User 's Query |
C_sharp : I have a class library with numerous EF6 entities . I generated a NuGet from this library . Whenever I reference the library directly only the DLL is placed in the bin , however when I install the library via NuGet it copies over the entities *Content.tt and *.tt files into a folder in the project.I have a co... | NuGet vs Direct Reference of Class w/ EF6 Entities |
C_sharp : I have a string like this : I want to do a replacement on this string such that each word ( case-insensitive ) will be matched , and replaced with a numbered index span tag like so : I tried doing it like this.The output is something like this : Where all the ids are the same ( m_1 ) because the regex does n'... | C # Regex change replacement string for each match |
C_sharp : I 'm toying around with the idea of using C # 's ability to compile code on-demand as the basis of a scripting language . I was wondering , how can I sandbox the scripts that I am executing so that they can not access the file system , network , etc . Basically , I want restricted permissions on the script be... | Assembly.CreateInstance and security |
C_sharp : I was trying to create my own factorial function when I found that the that the calculation is twice as fast if it is calculated in pairs . Like this : Groups of 1 : 2*3*4 ... 50000*50001 = 4.1 secondsGroups of 2 : ( 2*3 ) * ( 4*5 ) * ( 6*7 ) ... ( 50000*50001 ) = 2.0 secondsGroups of 3 : ( 2*3*4 ) * ( 5*6*7 ... | Why is it faster to calculate the product of a consecutive array of integers by performing the calculation in pairs ? |
C_sharp : I have a Main method like this : Since I am accessing a local variable b here the compiler creates a class to capture that variable and b becomes the field of that class . Then the b lives as long as the life time of the compiler generated class and it causes a memory leak . Even if b goes out of scope ( mayb... | Why ca n't the compiler optimize closure variable by inlining ? |
C_sharp : I have the following entities : An account class with a list of subscriptions : the subscription class with a list of variations and add ons : the add on class with a list of variations : And the variation class : What I 'm trying to do is to group all add ons with specific Code and sum the quantity . For exa... | Linq Group by and sum problems |
C_sharp : I want to create a new group when the difference between the values in rows are greater then five.Example : should give me 3 groups : Is it possible to use Linq here ? Thx ! <code> int [ ] list = { 5,10,15,40,45,50,70,75 } ; 1 , [ 5,10,15 ] 2 , [ 40,45,50 ] 3 , [ 70,75 ] | How can I group by the difference between rows in a column with linq and c # ? |
C_sharp : Databound to an ObservableCollection , I am filling an ItemsControl with Buttons . I am using UniformGrid to help evenly spread things out whether there are 5 or 5000 objects in the ObservableCollection . Desire : After the user searches/filters the ObservableCollection , I would like to update an IsVisible p... | WPF - Hide items in ItemControl - > UniformGrid from taking up UI space based on databinding |
C_sharp : In my current application , I have the following MongoDB FindAndModify call to the MongoDB server Am I reinventing yet another queue system with MongoDB ? That 's not my intention here but it 's what it 's . Just ignore the business logic there.In CQRS , Query and Command mean the following ( I believe ) : Co... | Where does FindAndModify fit into CQRS ? |
C_sharp : I declare a Byte-Array like this : and assign some values : Now I want to zero the array again and call : which does n't work . The array remains unchanged . Is n't b a value-type array ? <code> Byte [ ] b = new Byte [ 10 ] ; for ( int i=0 ; i < b.Length ; i++ ) { b [ i ] = 1 ; } b.Initialize ( ) ; | C # : Why does n't Initialize work with a Byte-Array ? |
C_sharp : Assume we have this model : I created a extension method for all classes that inherit from AbstractTableReferentielEntity.But for one specific type of AbstractTableReferentielEntity ( like EstimationTauxReussite ) , I would like to perform a specific action , so I created a second extension method.All extensi... | Extension methods with interface |
C_sharp : I 'm currently working on a desktop tool in .NET Framework 4.8 that takes in a list of images with potential cracks and uses a model trained with ML.Net ( C # ) to perform crack detection . Ideally , I 'd like the prediction to take less than 100ms on 10 images ( Note : a single image prediction takes between... | C # ML.Net Image classification : Does GPU acceleration help improve the performance of predictions and how can I tell if it is ? |
C_sharp : Causes : Struct member 'Unit.u ' of type 'Unit ' causes a cycle in the struct layout.Butcompiles . I understand the problem I suppose . An endless cycle will be formed when referencing a Unit object since it will have to initialize another member Unit and so on . But why does the compiler restrict the problem... | Why is there no cyclic layout issue for classes in C # ? |
C_sharp : I created a simple UWP application with no code , just XAML.If I zoom in to about US state level , the application will crash with an unhandled exception.The event viewer Application Log shows : I 'm running on Windows 10 Version 20H2 ( OS Build 19042.630 ) .How can I fix or diagnose this crash further ? Upda... | UWP MapControl crashes after zooming in |
C_sharp : I am writing a method that will take a screenshot of a passed form element , and print it out . There are a few challenges I am facing . I want to be able to make this method generic enough to accept just about any type of form element . I set the `` element '' argument to type `` object '' . I think I will a... | Accepting Form Elements As Method Arguments ? |
C_sharp : How do I convert this date to `` 20110504 14:33:41 '' ? <code> DateTime date = DateTime.Parse ( `` 2011-05-04 14:33:41 '' ) ; //4 may 2011 | DateTime format string |
C_sharp : I 'm having a hard time understanding why it would be beneficial to do something like this : ( Sample is a class ) Would n't it be better to to just pass Sample into the method ? <code> static void PrintResults < T > ( T result ) where T : Sample static void PrintResults ( Sample result ) | What is the purpose of a restricting the type of generic in a method ? |
C_sharp : The following pair of functions attempt to replicate the null conditional operator available in C # 6.0 : The first function is constrained to classes and for a String s allows me to write something like : The second function is where I am running into trouble . For example , given a int ? number I would like... | C # why is this type inferred method call ambiguous ? |
C_sharp : If there are n properties , then is the Big-O of .GetProperties O ( n ) or are there are processes involved in the reflection that add complexity ? Say there is this defined class : And then this call is made : What is the time complexity , i.e . Big-O , of .GetProperties ( ) ? Considering that there are 4 pr... | Big-O of .GetProperties ( ) |
C_sharp : I am trying to understand how events can cause a memory leak . I found a good explaination at this stackoverflow question but when looking at objects in Windg , I am getting confused with the result . To start with , I have a simple class as follows.Now I am using this class in a windows form application as f... | Why this does not cause a memory leak when event is not unsubscribed |
C_sharp : I want to iterate through an enum so I can call a method with each value of that enum . How can I do that ? I want it instead to be something likeIs there a way to do this ? <code> enum Base { ANC , BTC , DGC } ; XmlDocument doc ; doc = vircurex.get_lowest_ask ( Base.ANC ) doc = vircurex.get_lowest_ask ( Base... | How to iterate through an enum in C # ? |
C_sharp : The example php regex ( below ) uses subroutine calls to work.If I try use it with the C # Regex class I get an error : Unrecognized grouping constructIs it possible to rewrite this in to C # regex syntax ? Would it be a simple translation , or does another ( regex ) approach need to be used ? If it is not po... | Is it possible to convert PHP Regex ( using subroutine calls ) to C # regex ? |
C_sharp : I noticed something in C # when dealing with custom objects that I found to be a little odd . I am certain it is just a lack of understanding on my part so maybe someone can enlighten me.If I create a custom object and then I assign that object to the property of another object and the second object modifies ... | C # odd object behavior |
C_sharp : All these string prefixes are legal to use in C # : Why is n't this ? One would have thought that the order of these operators does n't matter , because they have no other meaning in C # but to prefix strings . I can not think of a situation when this inverted double prefix would not compile . Is the order en... | Why ca n't I use @ $ prefix before strings ? |
C_sharp : Guys I have a `` best practice question '' For example I have this classes : What is recommended to pass ? Just what I need ( int-value type ) or the whole object ( reference type ) Im asking this because Im using LINQ on an app that I am making and I have created many entities where I should pass the IDs ( f... | What to pass ? Reference Object or Value Type ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.