text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : In the above code sample I create a circle and let it move around by pressing arrow keys . The state variable in question is the position of the circle , represented by a Vector2f object ( part of the SFML library ) My question relates to the end of the code segment , where I find the pressed key and then mov... | F # game development : Modifying state variables |
C_sharp : Consider the following methods in C # : Let 's look at the instructions generated by the compiler : For the Decimal method : For the Int64 method : For the DateTime method : Why is the DateTime.GetHashCode ( ) method being treated as a virtual call of Object.GetHashCode ( ) , considering there is an overridde... | Why is GetHashCode ( ) method compiled differently for DateTime compared to other structs ? |
C_sharp : I just created a simple project with if statements to check if the statement is true , but then I stumbled into something weird.This is my sample codenope , you read that right . And I typed that right also . I have left out the else statement , but I have created curly brackets for it . When I compile , it r... | Some Visual Studio 2010 or C # bug ? Or am I just dreaming ? |
C_sharp : I want to do something but not sure how to describe it . I have this classBut I want to be able to do thiswhich should implicitly call GetPersonByName ( `` John '' ) .Is that possible ? What do I need to add to the Company class ? Thanks in advance ! <code> public class Company { private List < Person > _pers... | C # - MyClass.MyProperty [ something ] |
C_sharp : Currently I have this : However , I want this attribute to decorate only the setter , not the getter . Is there a way to do that ? <code> [ SomeCustomAttribute ] public string Name { get ; set ; } | Can an Attribute be set only on the Setter of an Auto-Implemented Property ? |
C_sharp : QUESTION IS : If this issue is clear to you , please explain to me what im not seeing . My question is : How does ternary actually work ? To clarify my question : What does right to left associativity really mean here ? Why is associativity not the same as order of evaluation ? It is clearly like an if else s... | Ternary operator as both left operative and right operative.. or neither |
C_sharp : Other than testability , what 's the big advantage of utilizing D.I . ( and I 'm not talking about a D.I . framework or IoC ) over static classes ? Particularly for an application where you know a service wo n't be swapped out.In one of our c # application , our team is utilizing Dependency Injection in the w... | Other than testing , how is Dependency Injection any better than static classes/methods ? |
C_sharp : C # , using VS2010 and I 've got something that makes no sense.At startup my program needs to load several hundred k from text files . After ensuring the loading code was working fine I threw it in a background thread . So long as this is run from within the IDE everything 's fine but when it 's run standalon... | C # : Why is my background worker thread signaling done when it is n't ? |
C_sharp : I have a method which adds row to database ( sql server 2005 ) . Something is wrong with its because , when I have a row with UpdateDate 2000-12-31 23:59:59 it inserts 2001-01-01 00:00:00.000 . Is it possible ? Culture of environment is polish if it is important . It 's a magic for me : / } EDIT : my date : <... | 2001-01-01 00:00:00.000 inserted into database instead 2000-12-31 23:59:59 |
C_sharp : Possible Duplicate : What 's the difference between an object initializer and a constructor ? In c # you can construct an object like : With : or with : What is the diference between that kind of constructors ? <code> public class MyObject { int val1 ; int val2 ; public MyObject ( int val1 , val2 ) { this.val... | Constructors versus Initializors in C # |
C_sharp : My Silverlight 5 application hosted in an ASP.NET panel is not getting displayed in Firefox ( version 11 ) . However it works perfectly well in Chrome , IE and Safari . I am dynamically loading the Silverlight object as shown below . This is done to pass init parameters . ( which I removed for testing ) . I a... | Firefox does n't show dynamically added Silverlight 5 control |
C_sharp : Given the following method signature , why is it when a parameter is explicitly named the compiler is unable to automatically infer the type ? Visual Studio 2010 SP1 is able to infer the type and shows no warnings or errors.Calling it as described in CannotInferType and when attempting to compile it the compi... | Unable to infer generic type with optional parameters |
C_sharp : Has anyone seen a problem in .NET Core 1.1 where beneath the netcoreapp1.1\publish folder they end up with a bin folder that seems to loop on itself and eventually causes a path too long message to appear in Windows . Trying to delete this folder in Windows Explorer cause a Source Too Long message to appear .... | Crazy Deep Path Length in .Net Core 1.1 |
C_sharp : I have defined the following delegate types . One returns a string , and one an object : Now consider the following code : Why is the assignment not valid ? I do not understand . A method which returns a string should be safely considered as a method which returns an object ( since a string is an object ) .In... | Why does the following example using covariance in delegates not compile ? |
C_sharp : How do you pin to start special folders using powershell ? Like `` ThisPC '' , iexplorerThis will pin to start exe 's fine , but what about windows explorer and myComputer ? How to pin those items since they have no target ? Given thisIt seems to have issues with .lnk 's for `` This PC '' , `` File Explorer '... | How To Pin To Start Special Folders With No Target |
C_sharp : I 'm using T4Template and codeDOM to create an assembly using the following code : The Template looks like this ( for moment ) : In the Main application I have a byte array which contains some bytes of a certain application , these bytes are loaded into the array at runtime.My question is : How can I pass the... | Pass an array of bytes to T4 Template code into another array of same type |
C_sharp : When you read MSDN on System.Single : Single complies with the IEC 60559:1989 ( IEEE 754 ) standard for binary floating-point arithmetic.and the C # Language Specification : The float and double types are represented using the 32-bit single-precision and 64-bit double-precision IEEE 754 formats [ ... ] and la... | Single-precision arithmetic broken when running x86-compiled code on a 64-bit machine |
C_sharp : I need to call a server that exposes an action.This action has either a string of a collection of complex types or a collection of complex types as parameters . I need to call either.Metadata is : either : With the following complex type : Or , alterantively : with the complex types defined asI see no way to ... | C # odata action with complex type collection fails |
C_sharp : I am trying to write my own Game of Life , with my own set of rules . First 'concept ' , which I would like to apply , is socialization ( which basicaly means if the cell wants to be alone or in a group with other cells ) . Data structure is 2-dimensional array ( for now ) .In order to be able to move a cell ... | Looking for ideas how to refactor my algorithm |
C_sharp : I 'm trying to understand how `` this '' gets passed around as a property in C # -6.0 ( VS 2015 ) .My assumption is that when the line : Person secondPerson = firstPerson.myself ; is run , that secondPerson becomes a reference to firstPerson , so when I change the name to `` Bill '' , firstPerson.name and sec... | How is `` this '' passed in C # |
C_sharp : I 'd like to develop a self training algorithm for a specific problem . To keep things simple i 'll nail it down to simple example.Update : I have added a working solution as answer to this question below.Let 's say i have a huge list of entities coming from a database . Each entity is of the same type and ha... | Self Training Algorithm |
C_sharp : The compiler complains : Can not implicitly convert type 'System.Collections.Generic.List < Tests.Program.FooStruct > ' to 'System.Collections.Generic.IEnumerable < Tests.Program.IFoo > ' . An explicit conversion exists ( are you missing a cast ? ) Why ? Why is there a difference between classes and structs ?... | Struct vs class implementing an interface |
C_sharp : I have the following code : Where : What this code does is execute certain SQL statement across a multitude of db connections , where some connections may belong to one DB server , while others - to another and so on.The code makes sure that two conditions hold : The SQL statements are run in parallel across ... | How should I propagate task exception from continuation task in .NET 4.0 ? |
C_sharp : I have this code : and I want to refactor the code separating the key / function definition from theactions . Key.xxx and Function.xxx are n't from the same type.eg : in Python , I could simply do something like : What 's `` the right way '' to do in C # ? <code> if ( PsionTeklogix.Keyboard.Keyboard.GetModifi... | What 's the C # pattern to perform an action on a series of values ? |
C_sharp : I noticed that a struct wrapping a single float is significantly slower than using a float directly , with approximately half of the performance.However , upon adding an additional 'extra ' field , some magic seems to happen and performance once again becomes more reasonable : The code I used to benchmark the... | Why does adding an extra field to struct greatly improves its performance ? |
C_sharp : Has anyone tried to stack contexts and use Tasks at the same time ? I 'm trying something like this : and I 'm getting that result : I was expecting it to have [ Saving Data ] instead of [ ( null ) ] on the second line.It appears to lose access to the log4net ThreadContext Stack as soon as it starts a new Tas... | Conflict between Log4Net 's ThreadContext and Task |
C_sharp : I have this [ nasty ] regex to capture a VBA procedure signature with all the parts in a bucket : Part of it is overkill and will match illegal array syntaxes ( in the context of a procedure 's signature ) , but that 's not my concern right now.The problem is that this part : breaks when a function ( or prope... | Parsing signatures with regex , having `` fun '' with array return values |
C_sharp : I have a weighted choice algorithm that works , but I 'd like to improve it in two aspects ( in order of importance ) : Guarantee that a minimum number from each possible choice is chosen.Reduce computational complexity from O ( nm ) to O ( n ) or O ( m ) , where n is the requested number of randomly chosen i... | Constrained weighted choice |
C_sharp : To reproduce : Download https : //github.com/nventive/Uno.QuickStartAdd a .NETStandard2_0 project called TestMe.Reference TestMe in the MyApp.Droid project.Building MyApp.Droid brings compile error : System.InvalidOperationException : The project ( s ) TestMe did not provide any metadata reference . This may ... | Referencing a .netstandard2_0 project in a platform.uno project |
C_sharp : Consider the following benchmark : BenchmarkDotNet reports the following results on .net framework 4.8 and .net core 3.1 : From the result , it seems that GetEnumerator causes a heap allocation when the array is not empty , but not when the array is empty . I 've rewritten the benchmark in many different ways... | Why does enumerating an empty array does not allocate on the heap ? |
C_sharp : One of the things that you have beaten into you as a junior developer is that you never , ever do a `` SELECT * '' on a data set , as it is unreliable for several reasons.Since moving over to Linq ( firstly Linq to SQL and then the Entity Framework ) , I have wondered if the Linq equivalent is equally frowned... | Linq no-noes - the catch all sql-like select ? |
C_sharp : I have a few infinite generator methods , including some long-running and infinitely-long-running generators.My goal is to have an infinite sequence that combines the items from the two examples . Here 's what I tried , using PLINQ : This seems appropriately combines the two IEnumerables into a new one , with... | Pitfalls of trying to use PLINQ over long-running generators ? |
C_sharp : I was looking at some code I 've inherited and I could n't decided if I like a bit of code.Basically , there is a method that looks like the following : It returns true if it connects successfully , false otherwise.I 've written code like that in the past , but now , when I see this method I do n't like it fo... | Should a connect method return a value ? |
C_sharp : Problem : We make extensive use of a repository pattern to facilitate read/write operations on our datastore ( MS SQL using LINQ ) across multiple applications and subsections of functionality . We have series of methods that all do something similar to each other.For example , we have the ProcessAndSortXXXXX... | Building a common set of methods that can operate on any linq table |
C_sharp : Let 's say I have some basic interface which is generics-driven : Now I have some concrete implementation of this interface which is also generic : This looks OK , but now let 's say I have other class : And let 's say I want to perform a check if TShouldModelInterface actually implements any of the possible ... | C # generics question - generic interface constraint |
C_sharp : To start with , this is not the same as Why is Func < > created from Expression > slower than Func < > declared directly ? and is surprisingly just the opposite of it . Additionally , all links and questions that I have found while researching this issue all originate out of the 2010-2012 time period so I hav... | Why Is a Compiled Delegate Faster Than a Declared Delegate ? |
C_sharp : It is possible to bind actions ' parameters via : [ FromBody ] Request body [ FromForm ] Form data in the request body [ FromHeader ] Request header [ FromQuery ] Request query string parameter [ FromRoute ] Route data from the current request [ FromServices ] I often need to extract something from a JWT , al... | Bind ASP.NET Core action parameter to JWT claim |
C_sharp : I have tried to search for the duplicates of my problem , but could not find . Also , sorry for the not so understandable title . I am so confused about what I am searching , and also about the terminology . I am an electronics engineer with very little knowledge on .Net framework , so treat me well : ) My cu... | How to convert string to int then to string ? |
C_sharp : I do not know how to describe my problem , but imagine having a TextBox in WPF with a long text . I have set TextWrapping= '' Wrap '' to prevent the whole string being displayed in one line , but I want my sting to be shown as follows : Instead of this : The difference is , that the first text has a 'hard cut... | Break words in textbox ( with TextWrapping=Wrap ) |
C_sharp : We all know that the using statement is really good for resources you want to cleanup in a timely manner , such as an open file or database connection.I was wondering if it would be considered a good thing to use the statement in cases where resources cleanup is n't the goal of the Dispose ( ) method , but ra... | Using 'Using ' for things other than resource disposal |
C_sharp : During answering on one of questions I saw 2 examples of LINQ code which should work exactly same . But I was wonder about performance , and found that one code much faster that another code . And I can not understand why . I took datastructures from questionthen I wrote simple benchmark tests ( used benchmar... | Linq to objects : inner query performance |
C_sharp : I 've been struggling to adapt my standard approach for test-driving .NET code to Ruby.As an example , I am writing a class that will : Normally for .NET I 'd end up with something like : In my test ( written first ) , I 'd mock finder and converter . Then I 'd stub out finder.FindFiles ( `` *.markdown '' ) t... | How to move from .NET-style TDD to Ruby ? |
C_sharp : My application receives push notifications well when the application is closed . But when the app is running , I get nothing . This is the same code that I have used in previous apps with out any problems , those were on WindowsPhone8 and the new apps are running on WindowsPhone8.1 devices.I used this Push Tu... | PUSH not showing when App is open |
C_sharp : I am a beginner to C # and I am picking it up by solving data structures case scenarios . I need help visualizing what is happening in the following code snippet What part I have understood I am aware that a new node is being added at the end of the linked list . Also , the new node is getting its value from ... | Linked Lists : When adding a element why is current.Next pointing to the new Node , and why do we overwrite the Current Node |
C_sharp : Suppose I have written such a class ( number of functions does n't really matter , but in real , there will be somewhere about 3 or 4 ) .I wonder if the C # compiler can optimize such a code so that it wo n't go through numerous stack calls.Is it able to inline delegates at compile-time at all ? If yes , on w... | Delegate stack efficiency |
C_sharp : Is there a difference between the following two pieces of code ? I found that our code base uses the second way of writing . <code> class Test { public readonly double Val ; public Test ( bool src ) { this.Val = src ? 1 : 0 ; } } class Test { public readonly double Val ; public Test ( bool src ) { this.Val = ... | Is there a difference between `` double val = 1 ; '' and `` double val = 1D ; '' ? |
C_sharp : I have a Silverlight app that uses actions to get data from the model ( which again gets the data from WCF services ) .I need to somehow sync two ActionCallbacks , or wait for them , and then execute some code.Example : I know I can use a counter to keep track of how many has returned , but is there not a bet... | Syncronizing actions in Silverlight |
C_sharp : Recently I edit C # code in vim . And the build system has StyleCop enabled so that all using statement should be in alphabetical order.So , I tried to select below lines of code in visual mode , then type `` : sort '' .The result is : It does n't pass StyleCop checking because `` System.Security '' is not ah... | How to sort using statement of C # code in vim ? |
C_sharp : There is a view displaying 5 dropdown lists populated with all available courses from relevant table : Student will select one course from each dropdown lists and press Register button.My question is how I will get selected courses in relevant controller ? Thanks . <code> @ model StudentRegistrationPortal.Mod... | Get selected values from multiple selectlists in MVC3 controller |
C_sharp : I wrote this simple linq-to-xml query and it seems that null exception could not be avoided using the the linq syntax . Am I using it wrong ? What should be the right ( and short ) Linq2Xml syntax ? The linq2Xml queryThe XML <code> var userData = queryUserResponseData.Elements ( `` user '' ) .Single ( u = > u... | How to use linq2Xml without the possibility of a null exception ? |
C_sharp : I have noticed the following enum declaration while browsing some sample code . What does None=1 mean ? <code> public enum ButtonActions { None = 1 , Clear , Insert , Delete , Cancel , Close } | What does None=1 refer in the following enum class ? |
C_sharp : I have a form with two custom panels and I 'm adding some labels to them and in the end i want they to scroll from the right to the left but they are just stucking in the same position.There is a screenshot of what i haveThere are two panels and the 4 labels and they just stay stuck in there ... This is the c... | c # flow layout labels got stuck |
C_sharp : I want to understand the difference between andI actually want to understand what is the benefit of creating a new object using `` using '' instead of creating it directly like this <code> public DataTable ExectNonActQuery ( string spname , SqlCommand command ) { using ( DataTable dt = new DataTable ( ) ) { c... | What is the benefit of `` using '' |
C_sharp : I was recently reviewing some code written by two different contractors , both were basic ASP.NET management sites . The sites allowed the user to view and edit data . Pretty much simple CRUD gateways.One group did their best to use built in ASP + AJAX Toolkit controls and did their best to use as many built ... | Best practices for developing simple ASP.NET sites ( built in controls or JQuery + scripts ) |
C_sharp : Sorry if this is a really basic question but it 's been really getting to me . I really like the idea of DI , it really helps me with my testing but I have hit a bit of a brick wall I think . So I have two types : Now the table object has a constructor on it like this : Now the table object pretty much only u... | DI object graph building - separating logic and construction graph |
C_sharp : Now with C # 7 , we can return by ref with return ref . From what I 've gathered , references are 32 or 64 bits . Now , if I had a struct Coord with a long X and long Y , that would be 128 bits , so it 'd be easier return the coord , ( as well as pass it ) by reference to avoid copying the 128 bits . On the o... | Should we always return by ref if we can ? |
C_sharp : Ok so after reading Albahari 's Threading in C # , I am trying to get my head around Thread.MemoryBarrier ( ) and Out-of-Order Processing.Following Brian Gideon 's answer on the Why we need Thread.MemoerBarrier ( ) he mentions the following code causes the program to loop indefinitely on Release mode and with... | Explanation of Thread.MemoryBarrier ( ) Bug with OoOP |
C_sharp : I was looking at the Routing Concepts of MVC and specifically at the below line : Everything 's fine , but I do n't get the significance of the Route Name.Is it just a term out there ? or is there anything significant with it ? Am I missing using it or where are the places it is used in MVC 4 ? Thanks in adva... | Significance of the Route Name in MVC 4 |
C_sharp : I have much more experience in Spring and Java , but now I am working on ASP.NET Web API project.So in Spring there is @ JsonView annotation with which I can annotate my DTOs , so I could select which data I will show through REST . And I find that very useful . But I can not find any equivalent in ASP.NET . ... | Is there @ JsonView equivalent in ASP.NET Web API |
C_sharp : Do Volatile.Read and Volatile.Write have the exact same effect on a nonvolatile int that normal reads and assignments have on an int with the volatile modifier ? The motivation is to prevent the warning that volatile variables should not be passed via ref parameters to the Interlocked methods . ( I understand... | What is the difference between the volatile modifier and Volatile.Read/Write ? |
C_sharp : Suppose I have two functions which look like this : What would be a good way to avoid repeated dostuff ? Ideas I 've thought of , but do n't like : I could make d an object and cast at runtype based on type , but this strikes me as not being ideal ; it removes a type check which was previously happening at co... | Reducing Code Repetition : Calling functions with slightly different signatures |
C_sharp : I was looking at the memory impact of a simple LINQ query and noticed that the LINQ query created 2 extra objects of types Enumerable+WhereListIterator < Int32 > and Func < Int32 , Boolean > . The code used is this : At the snapshot after the foreach loop I notice that the Enumerable+WhereListIterator < Int32... | Why does a GC after a LINQ query free the WhereListIterator but not the Func representing the condition ? |
C_sharp : For example , we have two domain objects : Cell and Body ( as in human cell and body ) .The Body class is just a collection of Cells , e.g.The Cell has a Split method , which internally creates a clone of itself , e.g.Now , in DDD when the cell splits should : The cell add the newly created cell to the Body (... | In Domain Driven Design when an entity clones itself who adds it to its container ? |
C_sharp : Possible Duplicate : What 's the use/meaning of the @ character in variable names in C # ? C # prefixing parameter names with @ I feel like I should know this and I find it impossible to google.Below is an excerpt from some Linq code I came across : What does the ' @ ' prefix mean in this context ? <code> pri... | Linq , lambda and @ |
C_sharp : I have a function to generate an expression to be used in a linq Where clause . ( note IActive only defines the property 'Active ' ) There are other related functions and the idea is that i can inject the required conditions into a Generic class to control business rules , etc.The problem is that when I run t... | Expression < Func < T , bool > > adds an unwanted Convert when created in generic method |
C_sharp : I have an enum which describes options available for a user to select as part of settings . This is serialized to XML . One of the names is not ideal , and I 'd like to rename it , but still support deserialization of older settings files.For example : I know I can rename it but specify the previous serialize... | How can I rename an enum which is serialized to XML but continue to support previous names ? |
C_sharp : I 'm trying the following code.. I get the following error : Query operator 'Count ' is not supported . I want to basically be able to specify a Where In clause instead of Where =.Anyone has an idea of how I can achieve this ? <code> LoadOperation < Tasks > PhasesLP = context . Load ( context.GetTasksQuery ( ... | WCF RIA - Query operator 'Count ' is not supported |
C_sharp : I use the `` is '' operator to find a certain class : This works fine especially as it finds any class that inherits from the ScreenBase but not the base classes from ScreenBase.I would like to do the same when I know only the Type and do n't want to instantiate the class : But this comparsion produces a warn... | `` is '' - operator for Type |
C_sharp : After adding < Nullable > enable < /Nullable > or # nullable enable , I ran into the following problem with my Generic methods : This does not work : This works with warning : This works individually , but not together.Logically , the first method should work.What is the correct way ( in any framework ) out o... | A problem with Nullable types and Generics in C # 8 |
C_sharp : When attempting to use the C # `` as '' keyword against a non-generic type that can not be cast to , the compiler gives an error that the type can not be converted.However when using the `` as '' keyword against a generic type the compiler gives no error : I discovered this behaviour in a much larger code bas... | Conflicting compile time behaviour using as keyword against generic types in C # |
C_sharp : Possible Duplicate : String concatenation vs String Builder . Performance Any difference ( performance and memory usage ) between the following two options ? option 1 : options 2 : <code> StringBuilder msgEntry = new StringBuilder ( ) ; msgEntry.AppendLine ( `` < `` + timeTag + `` > '' + timeStamp + `` < / ''... | which string operation is better ? |
C_sharp : I 'm looking to create a function that accepts any task that produces an IEnumerable < T > . To illustrate , consider the following function signature.Now , I would like to call this method as follows : Clearly , this does n't work since the two Task types are not the same , and that covariance does n't exist... | How do I define a function that accepts any Task producing an IEnumerable < T > ? |
C_sharp : I have a class defined as : When I run Node.Load ( ) from a codebehind ( Window.xaml.cs ) the Node 's static constructor never fires ; or at least does n't hit a breakpoint and does not set Node.Query to anything other than null.Is there any reason why this might occur ? SolutionCheck out the answers below fo... | Child static constructor not called when base member accessed |
C_sharp : I have a use case where the text has to be encoded and sent using the AES 256 algorithm . The client-side code is in C # which would be decrypting the code.Encryption code in JS : Updated code used in the client side : The keyString and IV value used are same in C # and is encrypted using Utf8 . Looking for t... | AES encryption in Node JS and C # gives different results |
C_sharp : Suppose I have a custom collection class that provides some internal thread synchronization . For instance , a simplified Add method might look like this : The latest Code Contracts complains that CodeContracts : ensures unproven : this.Count > = Contract.OldValue ( this.Count ) . The problem is that this rea... | Collection Contracts and Threading |
C_sharp : Sample String The regex should match and should not match [ 000112 ] since there is outer square bracket.Currently I have this regex that is matching [ 000112 ] as well <code> `` [ ] [ ds* [ 000112 ] ] [ 1448472995 ] sample string [ 1448472995 ] *** '' ; [ 1448472995 ] [ 1448472995 ] const string unixTimeStam... | Regex to get square brackets containing numbers only but are not within square brackets themselves |
C_sharp : Possible Duplicate : What is the = > token called ? Hey , In LINQ what is the name of the = > operator e.g : <code> list.Where ( a = > a.value == 5 ) ; | The name of the = > operator in C # |
C_sharp : Recently I started working on trying to mass-scrape a website for archiving purposes and I thought it would be a good idea to have multiple web requests working asynchronously to speed things up ( 10,000,000 pages is definitely a lot to archive ) and so I ventured into the harsh mistress of parallelism , thre... | Asynchronous Tasks 'Clogging ' |
C_sharp : I 've just found a bug in my program ( after some amount of debugging and tearing my hair ) As you can see firstis always true - never changed . So if ( ! first ) is basically if ( false ) .The compiler did not generate a warning although it is set to level 4 ( highest level ) .How can I find similar if ( fal... | c # : Finding Bugs : if ( false ) |
C_sharp : Sample code to illustrate : I 'm seeing res1 = -1 , and res2 = 1 at the end , which was a bit unexpected . I thought res1 would return 1 , since on an ASCII chart `` A '' ( 0x41 ) comes before `` a '' ( 0x61 ) . Also , it seems strange that for res2 , the length of the string seems to make a difference . i.e ... | String.CompareTo with case |
C_sharp : HashSet.Contains implementation in .Net is : And I read in a lot of places `` search complexity in hashset is O ( 1 ) '' . How ? Then why does that for-loop exist ? Edit : .net reference link : https : //github.com/microsoft/referencesource/blob/master/System.Core/System/Collections/Generic/HashSet.cs <code> ... | How can hashset.contains be O ( 1 ) with this implementation ? |
C_sharp : I have two large lists of object . First ( about of 1 000 000 objects ) : Second ( about of 20 000 objects ) : I need to find all Traider items in Base items when DateUtc are equals and Fee are equals . Now i am using Any method : But this way is very-very slow . Is there a way to make this more efficient ? I... | Filter large list object on data from another large list : slow performance |
C_sharp : I am aware of the constructor difficulty in Xamarin Android as is explained here : No constructor found for ... ( System.IntPtr , Android.Runtime.JniHandleOwnership ) and all the fragments & activities & other custom views that I create in the app import this constructor.Sometimes however a null reference exc... | Will Xamarin Android execute OnCreateView when the IntPtr constructor is called ? |
C_sharp : I have a large third party webservice ; the reference.cs is 33 Mbyte . Using Visual Studio 2017 , the proxy uses the XML Serializer , which causes a 5 second delay when creating the channel . I opened a case at Microsoft , and they showed me partially how to modify the reference.cs to use the Datacontract ser... | Can the data contract serializer used for any third party webservice |
C_sharp : I am reading this blog : Pipes and filters patternI am confused by this code snippet : what is the purpose of this statement : while ( enumerator.MoveNext ( ) ) ; ? seems this code is a noop . <code> public class Pipeline < T > { private readonly List < IOperation < T > > operations = new List < IOperation < ... | Help me understand the code snippet in c # |
C_sharp : When coding C # I often find myself implementing immutable types . I always end up writing quite a lot of code and I am wondering whether there is a faster way to achieve it.What I normally write : This gets fairly complicated when the number of fields grows and it is a lot of typing . Is there a more efficie... | How to efficiently implement immutable types |
C_sharp : What algorithm can I use to find the set of all positive integer values of n1 , n2 , ... , n7 for which the the following inequalities holds true.For example one set n1= 2 , n2 = n3 = ... = n7 =0 makes the inequality true . How do I find out all other set of values ? The similar question has been posted in M.... | find the set of integers for which two linear equalities holds true |
C_sharp : In deferred ( with impoersonate = no ) to send the Value to the WIX to CA , i am using set property and valueand collecting the data in CA using session.CustomActionData [ `` key '' ] ; Is there any way to send back the data to the WIX from CAIn immediate i was using , ... how to achieve this in deferred CA <... | Wix Custom action set value from CA to wix |
C_sharp : I 'm trying to make a List < byte > from a file that contains string ( Hexadecimal ) .the definition is : if I want to add my information directly I use something like this : Note : Without any quotation or double-quotation .The problem is when I want to do the same thing from file ! Now I want to know what 0... | Add hexadecimal from file to List < byte > |
C_sharp : Is there a way to unwrap the IObservable < Task < T > > into IObservable < T > keeping the same order of events , like this ? Let 's say I have a desktop application that consumes a stream of messages , some of which require heavy post-processing : I imagine two ways of dealing with that.First , I can subscri... | Unwrapping IObservable < Task < T > > into IObservable < T > with order preservation |
C_sharp : I do n't know if that 's been asked before , but I have n't been able to find an answer , nonetheless . My question is this ; in For loops , this is acceptable.But this is NOT : Why is it that I can not use '== ' to determine whether the condition has been met ? I mean , both expressions return true or false ... | Why is it that I ca n't use == in a For loop ? |
C_sharp : I 've recently encountered an error `` ObjectDisposedException : Can not access a closed Stream '' when using code following the format : So the exception is caused because the Dispose of the TextWriter Disposes the Stream ( hashStream ) that is wrapped . My questions are thus : Does this convention applied (... | Who owns wrapped streams ( e.g . TextWriter ) in .NET ? |
C_sharp : I 've started reading Jon Skeet 's early access version of his book , which contains sections on C # 4.0 , and one thing struck me . Unfortunately I do n't have Visual Studio 2010 available so I thought I 'd just ask here instead and see if anyone knew the answer.If I have the following code , a mixture of ex... | Does C # 4.0 and a combination of optional parameters and overloads give you a warning about ambiguity ? |
C_sharp : Okay here we go : Stream.html ( Template file ) Default.aspx ( jQuery ) Update : The above has been changed to : Issues with jQuery : I have comments that belong to each .streamItem . My previous solution was to use ListView control as follows : So as you can see , this is not a solution since I started using... | CSS + jQuery - Unable to perform .toggle ( ) and repeated jQueryTemplate Item [ I must warn you this is a bit overwhelming ] |
C_sharp : I am seeing this strange issue , and ca n't find anything similar to this anywhere on the web : I tried this in various C # projects and even asked another developer to confirm the behaviour is identical in a different project on a different machine . I tried the same in VB.NET : Am I loosing it ? <code> int ... | Why `` K '' .Length gives me wrong result ? |
C_sharp : I have a method SaveChanges < T > ( T object ) that is frequently called throughout my code , except depending on the action calling the method , there would be a different method called from within SaveChanges . Something like this ... Usage Examples : I 've read up on delegate methods but I 'm a little conf... | Passing a method as an argument |
C_sharp : I 'm calling a third-party API which has a method that looks like this : My challenge is , I have to call Discover because it does some work under-the-covers that I need . At the same time , I have to wait for Discover to complete before running my custom code . To further complicate matters , I ca n't just p... | Awaiting a Callback method |
C_sharp : I have a C # project working with input audio Stream from Kinect 1 , Kinect 2 , Microphone or anything else.The buffer variable is a Stream from component A that will be processed by a SpeechRecognition component B working on Streams.I will add new components C , D , E , working on Streams to compute pitch , ... | How can I split and pipe multiple NAudio stream |
C_sharp : Trying to construct nameof expression from scratch using C # SyntaxFactory . Roslyn fails to recognize my InvocationExpressionSyntax as a contextual nameof keyword and throws error diagnostics upon Emit command.Tried to give Roslyn valid code to parse in hope that I 'll find differences between my syntax cons... | Constructing NameOf expression via SyntaxFactory ( Roslyn ) |
C_sharp : I saw thisbut I also saw thisWhat 's the difference ? <code> i > = 5 i = > 5 | What is the difference between > = and = > ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.