text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I have in xaml : And here is screenshot ( using magnifier ) : My question is what is going on here ? Why tooltip displays value differently ( decimal point is . while , is expected ) ? Longer story : I am trying to display numbers in same format as in user Windows number format preferences.For this I 've over... | Tooltip culture is wrong |
C_sharp : I try to find some information about method overloading resolution in case of presence of user-defined implicit conversions and about conversions priority.This code : Produces output : So , It looks like compiler chosen user-defined conversion instead of built-in implicit conversion from int to double ( built... | C # Method overloading resolution and user-defined implicit conversions |
C_sharp : Lets assume , we have an operation based on some file , connection , or other resource.We need a method , which can be run with provided resource , or - if not provided - creates own : } It works , but this is really ugly for me.Is it a way to write it in more compact and `` nice '' way ? I can not use : as i... | C # conditional using and default parameter |
C_sharp : I need a PHP version of the following C # code : ... this code snippet appears to be incomplete . But here 's what I think is going on : concatenating dateSince , siteID , and sharedSecret . Stealing underpants. ? ? ? converting that string into a ascii encoded byte array.taking the MD5 hash of that array.Thi... | How would I translate this C # code into PHP ? |
C_sharp : I have a Linq query with a select , from my Linq query provider it I get an expression tree containing a MethodCallExpression , but just how can I get the select projections from the MethodCallExpression ? Query may look like : <code> internal static object Execute ( Expression expression , bool isEnumerable ... | Getting projections from MethodCallExpression |
C_sharp : I am creating a console application for the purpose of learning the state and observer patterns . The program is based on a basic order system whereby each order can have a state ( pending , ready , submitted i.e state pattern ) and subscribers that are interested in receiving notifications from the order whe... | Should these interfaces be inherited at interface level or implemented at class level ? |
C_sharp : Imagine this C # code in some method : Let 's say no one is using any explicit memory barriers or locking to access the dictionary . If no optimization takes place , then the global dictionary should be either null ( initial value ) or a properly constructed dictionary with one entry.The question is : Can the... | Can another thread see partially created collection when using collection initializer ? |
C_sharp : So I made myself a C # -WebApi REST Service.When I build/run my application in Visual Studio everything works perfectly.But everytime I try to publish my project as a filesystem , two errors appear in the error list . The strange thing here is that these errors disappear after a few seconds and no errors are ... | Visual Studio 2013 publishing fails and reports `` non-existing '' error |
C_sharp : please look at the below code : and the result is : FalseTrueand now consider this one : and the result is : TrueTrue “ == ” compares if the object references are same while “ .Equals ( ) ” compares if the contents are same . and i want to know what is different between these codes ? ! and both of them turn o... | `` stringDemo '' versus new string ( `` stringDemo '' .ToCharArray ) ; |
C_sharp : 2nd edit : I think my original test script has an issue , the 10000000 times loop is , in fact , dealing with the same memory location of an array , which makes the unsafe version ( provided by Marc here ) much faster than bitwise version . I wrote another test script , I noticed that bitwise and unsafe offer... | C # Signed & Unsigned Integral to Big Endian Byte Array , and vice versa using Bitwise way with `` best '' performance |
C_sharp : I have a .NET Console App integrated with Entity Framework and Discord Sharp Plus with the following libraries : DSharpPlusDSharpPlus.CommandsNextMicrosoft.EntityFrameworkCore.DesignMicrosoft.EntityFrameworkCore.SqliteMicrosoft.EntityFrameworkCore.ToolsRunning the application without debugging ( Control + F5 ... | .NET Console App with Entity Framework Core : 'The process has no package identity ' only when started without debugging |
C_sharp : On my ASPX page I 've added Dropdownlist.Elements in this list are divided to groups by adding disabled list items : Those list items are grayed , I ca n't select it by mouse or by clicking cursor arrows ( up/down ) .That is correct.But problem is , that after clicking '- ' key this list item is selected . I ... | Error in Dropdownlist |
C_sharp : I 've written two LINQ queries using the join method . Essentially , if I switch the order of the objects to be joined , the query no longer works and throws the error : '' Unable to create a constant value of type 'Domain.Entities.UsersSitesRole ' . Only primitive types ( 'such as Int32 , String , and Guid '... | Why does this LINQ join query work , but this other one does n't ? |
C_sharp : I have the following code : This is a modified example from CLR via C # 4th ed ( pg 138 ) .In the book it says thatwill output `` ( 2 , 2 ) '' because the boxed p will be immediately garbage collected.However , would n't the actual reason for this be the fact that changing the value of a boxed variable only c... | Changing a struct after boxing it |
C_sharp : I am trying to read foreign characters from an .ini file.This is the method I am usingI am using Encoding.ASCII but apparently GetPrivateProfileString is n't . The bytes coming out of it need encoding probably . How can I do that ? Edit : ExampleThis will print : Tavar ? instead of Tavaré <code> [ DllImport (... | File read foreign characters |
C_sharp : Are there any C # specifications that state how implicit conversions of terms of integral types ( e.g. , int ) to terms of double are supposed to work ? If so , can someone tell me the algorithm or direct me to it ? C # 6.0 draft specification states “ the value of a real literal of type float or double is de... | How does C # implicitly cast terms of integral types to terms of double ? |
C_sharp : My class has a method which produces a Task < int > object using a TaskCompletionSource < int > . Then it does some asynchronous operations and sets the result . I need to know whether I can trust the task 's ContinueWith method or not : Can the caller of CalculateAsync method do something with the produced t... | How to cancel a task 's continuation ? |
C_sharp : I am currently cleaning up some of our legacy code base in which we make use of extern methods . The parameter names are all over the place in terms of naming conventions . I 'd like to consolidate them.ExampleCan I safely rename new_status to newStatus or will that break the contract ? ReSharper suggests it ... | Is it safe to rename extern method parameters in C # ? |
C_sharp : Does there exist a standard pattern for yield returning all the items within an Enumerable ? More often than I like I find some of my code reflecting the following pattern : The explicit usage of a foreach loop solely to return the results of an Enumerable reeks of code smell to me . Obviously I could abandon... | What is the proper pattern for handling Enumerable objects with a yield return ? |
C_sharp : I want to know is there a better/easier way to load users by birthday.I have a User instance , which has properties , including this one : public DateTime ? BirthDate { get ; set ; } What I want to do is to load that users who has bdays from one date to another : I do n't care about birthday year , for exampl... | Load users by birthday |
C_sharp : I 'm experimenting with switch statement pattern matching , and I 'm looking for a way to return false if either value in a two value tuple is zero . This is the code I 'm trying : In VSCode 1.47 and dotnetcore 3.14 I get a compile-time error : CS8652 : The feature 'type pattern ' is in Preview ` What is the ... | How to use C # pattern matching with tuples |
C_sharp : I was wondering how could I use a custom object in more than one panel.I made a panelModified object ( extends from Panel ) and want to place it in two normal panels , so when the object change its status , both panels display the updated information.In my case the `` panelModified '' is a panel with some But... | How can I show an object in multiple panels ? |
C_sharp : I have a class of this type : But sometimes I need to use this class as a non generic class , ie the type TResult is void.I ca n't instantiate the class in the following way : Also , I 'd rather not specify the type omitting the angle brackets : I do n't want re-write the whole class because it does the same ... | What if T is void in Generics ? How to omit angle brackets |
C_sharp : I stumbled across this article and found it very interesting , so I ran some tests on my own : Test One : Outputs : Test Two : Outputs : According to the article , in Test One all of the lambdas contain a reference to i which causes them to all output 5 . Does that mean I get the expected results in Test Two ... | odd lambda behavior |
C_sharp : I 'm trying to connect Chrome extension and my C # application.I 'm using this code https : //stackoverflow.com/a/13953481/3828636Everything is almost working there in only one problem I can send message only 6 times and than my c # app does n't recieve anything . When I re-open my extension ( click on icon )... | Communication JQuery and C # |
C_sharp : Executing a UWP application in DEBUG works perfectly.Using exactly the same code compiled in RELEASE crashes with this error message when executing this code ( it 's using Dapper 1.5.1 and System.Data.SQLite 1.0.109.2 ) The application is UWP configured as below . Furthermore , the faulting code is a .NET Sta... | PlatformNotSupportedException throws when using Dapper with WP |
C_sharp : I 'm trying to debug ( hit breakpoint ) a python script which is executed through a new process from C # .I have installed Child Process Debugging Power tool as that tool supposedly allows one to do that.According to its documentation it requires two things : The parent process must be debugged with the nativ... | Mixed mode Debugging Python/C # using Child Process Debugging Power Tool |
C_sharp : ** I have 36 of these case statements each one for another for a different picture box ; how do I group them all into one case statement so my code can be more efficient** <code> private void makeMoleVisable ( int mole , PictureBox MoleHill ) { switch ( mole ) { case 1 : if ( p01.Image == pmiss.Image & & Mole... | How do I merge all the cases into One ? |
C_sharp : The following code works if Cassandra and the code are on the same machine : Assuming a username and password is needed if the code is on one machine and cassandra is on a different machine ( different ip address ) ? So I have tried : I get the following error message : The iptables on the node ( the cassandr... | How do I connect to a Cassandra VM |
C_sharp : I have set up a VirtualPathProvider and it is working fine for direct url calls like http : // ... /home/index in the address bar.However , I would like this to work for the Html helper too , but right now it is ignoring the VirtualPathProvider for the html helper calls in the view : Is there a way to solve t... | Html helper does not use custom VirtualPathProvider |
C_sharp : This is a followup to this question : Cast < int > .Cast < int ? > applied on generic enum collection results in invalid cast exceptionWhy is that Gender [ ] is IEnumerable < int > returns true in the generic case ? Especially when they are not type compatible ? It had tripped me in the question I linked ! I ... | enum [ ] is IEnumerable < int > returns true in a generic method |
C_sharp : I think my logic is flawed ... .in a loop I have : this loop updates approximately once per second ... .the problem I have is that seconds always ends up with a zero ( 0 ) value . this is because the ItemPos value is always higher after first loop than elapsed.TotalSeconds . So for example : if 3 seconds pass... | Estimated time remaining , what am I missing ? |
C_sharp : I was working through the MSDN tutorial for Crystal Reports , and I get to the Binding the Embedded Report to the CrystalReportViewer Control step : When I try the build , it tells me that I am missing my using declaration for Hierarchical_Grouping class . This brings up two questions for me ... What is the n... | Missing Using directive for hierarchical_grouping in MSDN crystal reports tutorial |
C_sharp : Run enumeration of IAsyncEnumerable twice not possible ? Once CountAsync has been run , the await foreach wo n't enumerate any item . Why ? It seems there is no Reset method on the AsyncEnumerator.Source of data <code> var count = await itemsToImport.CountAsync ( ) ; await foreach ( var importEntity in itemsT... | Run enumeration of IAsyncEnumerable twice not possible ? |
C_sharp : My answer to one of the question on SO was commented by Valentin Kuzub , who argues that inlining a property by JIT compiler will cause the reflection to stop working . The case is as follows : Fuzz function accepts a lambda expression and uses reflection to find the property . It is a common practice in MVC ... | Property / Method inlining and impact on Reflection |
C_sharp : I have a 123MB big intarray , and it is basically used like this : eval ( ) is called a lot ( ~50B times ) with different c and I would like to know if ( and how ) I could speed it up . I already use a unsafe function with an fixed array that makes use of all the CPUs . It 's a C # port of the TwoPlusTwo 7 ca... | Speeding up array lookup after traversing ? |
C_sharp : I 've found very strange C # compiler behavior for following code : In last line assert fails with following message : I understand why test fails : p2 = new SqlParameter ( `` @ p '' , 0 ) ; is resolved as SqlParameter ( string , SqlDbType ) and for other cases as SqlParameter ( string , object ) . But I do n... | Strange C # compiler behavior ( overload resolution ) |
C_sharp : I have a few jobs executed one after the other via ContinueJobWith < MyHandler > ( parentJobId , x = > x.DoWork ( ) ) .However , the second job is not getting processed and always sits in Awaiting state : The job itself is like this : Why this can happen and where to check for resultion ? We are using Autofac... | Hangfire ContinueWithJob is stuck in awaiting state , though parent job has succeeded |
C_sharp : Is it possible somehow to define a constant that says what datatype to use for certain variables , similar to generics ? So in a certain class I would have something like the following : From the principle it should do the same as generics but I do n't want to write the datatype every time the constructor for... | C # : Declaring a constant variable for datatype to use |
C_sharp : I made an winform application that can detect , set and toggle IPv4 settings using C # . When the user wants to get IP automatically from DHCP I call Automatic_IP ( ) : Automatic_IP : And in the Getip method I extract the current IP address , subnet , gateway and the DNS regardless of the fact that all these ... | Detecting if `` Obtain IP address automatically '' is selected in windows settings |
C_sharp : I 'm developing a game using XNA and C # and was attempting to avoid calling new struct ( ) type code each frame as I thought it would freak the GC out . `` But wait , '' I said to myself , `` struct is a value type . The GC should n't get called then , right ? '' Well , that 's why I 'm asking here.I only ha... | What happens when value types are created ? |
C_sharp : I saw the following code , Based on my understanding , I think the code should be rewritten as follows : Is that correct ? Based on http : //msdn.microsoft.com/en-us/library/scekt9xw % 28v=vs.80 % 29.aspxAn is expression evaluates to true if the provided expression is non-null , and the provided object can be... | C # -- Is this checking necessary `` obj is Person & & obj ! = null '' |
C_sharp : I have two similar queries theoretically returning the same results : This request returns 0 items , even though it is supposed to return one.The following is a rewrite of the latter but with a call to the ToList ( ) method . This request works and returns the item expected in the first query ! Note : Session... | Unexpected Linq Behavior - ToList ( ) |
C_sharp : I am using HTML Agility pack in Xamarin forms to scrape data from a website . When a condition returns true , I want to send a push notification to all users . However , this data is changing a lot and I think it would cost a lot of internet data and maybe battery , if the device with this app is constantly c... | Use code on one device and show 'result ' with others using push notifications |
C_sharp : Can I write a hash code function for the following comparer logic ? Two instances of My are equal if at least two properites from ( A , B , C ) match.The Equals part is simple , but I 'm stumped on the hash code part , and part of me is thinking it might not be possible.UPDATE : In addition to the correct ans... | Is it possible to write a hash code function for an comparer that matches many-to-many ? |
C_sharp : The .NET reference source shows the implementation of NextBytes ( ) as : InternalSample provides a value in [ 0 , int.MaxValue ) , as evidenced by it 's doc comment and the fact that Next ( ) , which is documented to return this range , simply calls InternalSample . My concern is that , since InternalSample c... | Is Random.NextBytes biased ? |
C_sharp : I 'm currently writing a CLR profiler , and I came across something very odd . When throwing two different exceptions , one from the try clause and one from the catch clause , the CLR notifies me of the same instruction pointer.More specifically : I 'm registered to receive the ExceptionThrown callbackvirtual... | CLR Profiling : DoStackSnapshot after a throw inside a catch block gives wrong instruction pointer |
C_sharp : I 'm building a message dispatch map in C # and mostly just playing around with some different approaches . I am curious about a performance difference I am measuring , but it 's not obvious why from looking at the IL.The message map : I then have a class hierarchy of Messages , similar to EventArgs in WPF , ... | Why is casting to a generic type slower than an explicit cast in C # ? |
C_sharp : I am trying to derive a class from ObservableCollection and I need to run just a single line of code each and every time any instance of this class is deserialized . My thought was to do this : But I do n't have access to those base methods related to serialization . Am I forced to re-write all of the seriali... | How can I run code in a C # class definition each time any instance of the class is deserialized ? |
C_sharp : In MVC3 , we could use the CanvasAuthorize Attribute ( in old FaceBook version ) properties like LoginDisplayMode , ReturnUrlPath , CancelUrlPath.How can we use them in Latest version 6.4 ? We have [ FacebookAuthorize ( `` Permissions '' ) ] in the MVC4 . But , how we could use other properties like LoginDisp... | What is the substitute of CanvasAuthorizeAttribute in FaceBook C # SDK 6.4 version |
C_sharp : Assume I have a classNow I want to filter duplicates in list of such audio 's by similarity ( not EXACT match ) condition . Basicaly it 's Levenstein distance with treshold correction by string total length . The problem is , general tip about IEqualityComparer is `` Always implement both GetHashCode and Comp... | .net Distinct ( ) and complex conditons |
C_sharp : I want my View to be as follows : This leads me to believe I need a Model that contains a list of another Model . So in a project containing nothing but this I would have : Is this correct or is there a better way ? <code> @ model MyProgram.Models.DocumentList @ { ViewBag.Title = `` View1 '' ; } @ foreach ( M... | Simple best practices for ASP.NET models |
C_sharp : I understand that .NET is multi-threaded and that is a good thing , but I continually run into issues when I have a background worker for example that is updating some control on my form and I have to do : My question is why is this not built into the framework - surely if I am trying to update a DataGridView... | Why is n't Invoke via Delegate built into .NET |
C_sharp : I have a LinqToEntities query that double produces a subquery when creating the SQL . This causes the result set to come back with 0-3 results , every time the query is run . The subquery on its own produces a single random result ( as it should ) . What is going on here ? The LINQ query : Produce this SQL : ... | LinqToEntities produces incorrect SQL ( Doubled Subquery ) |
C_sharp : If I include outside reference inside where predicate then memory does not get releases.Let 's say I have a List < object > then if I write a where predicate like this : Even If I make myList = null or predicate = null , it is not releasing memory . I have List < object > itemsource binded to DataGrid . I als... | Where predicates does not releases memory |
C_sharp : I built an application that can also be ran as a service ( using a -service ) switch . This works perfectly with no issues when I 'm running the service from a command prompt ( I have something set up that lets me debug it from a console when not being ran as a true service ) . However , when I try to run it ... | Using memory maps with a service |
C_sharp : I have many working Entity Framework Scalar Function 's . However , when I try to return a 'truthy ' value through a scalar function I get the following exception : The specified method 'Boolean svfn_CanCloneDocument ( Int32 , System.String ) ' on the type 'ETC.Operations.DbClient.DbClient.Data.DbClientContex... | Bit-Bool on a Entity Framework Scalar Function Throws ' can not be translated ' Exception |
C_sharp : Let 's have two code snippets : A : B : In case A the CLR will not even call the Bar ctor ( unless it is debug build or the debugger is attached ) , however in case B it is called under all circumstances.The thing is that in Bar constructor one can have calls that will make this instance reachable from elsewh... | Why CLR optimizing away unused static field with initialization ? |
C_sharp : So I have been playing around with C # lately and I do n't understand output formatting.OutputMy expected output was index i holds number Number [ i ] . So can anyone explain what to change , or link me with a good C # page on output formatting topic.I know there is a way to do it in 2 lines . <code> using Sy... | Simple C # output |
C_sharp : I 've been playing around with optional parameters and came accross the following scenario.If I have a method on my class where all the parameters are optional I can write the following code : If I then create an interface such as : If I make the Test class implement this interface then it wo n't compile as i... | When interface method has no parameters why is n't the implementation recognised of a method with all optional parameters ? |
C_sharp : I am trying to implement a caching mechanism for enumerating collections safely , and I am checking if all modifications of the built-in collections are triggering an InvalidOperationException to be thrown by their respective enumerators . I noticed that in the .NET Core platform the Dictionary.Remove and Dic... | Dictionary methods Remove and Clear ( .NET Core ) modify the collection during enumeration . No exception thrown |
C_sharp : I am writing a simple Memoize helper that allows caching method results instead of computing them every time . However , when I try to pass a method into Memoize , the compiler ca n't determine the type arguments . Are n't they obvious from my method signature ? Is there a way around this ? Sample code : Erro... | Why do I have to explicitly specify my type arguments for Func parameters ? |
C_sharp : Running an empty for-loop with large numbers of iterations , I 'm getting wildly different numbers in how long it takes to run : The above will run in around 200ms on my machine , but if I increase it to 1000000001 , then it takes 4x as long ! Then if I make it 1000000002 , then it 's down to 200ms again ! Th... | for-loop performance oddity in .NET x64 : even-number-iteration affinity ? |
C_sharp : I am trying to enumerate a large IEnumerable once , and observe the enumeration with various operators attached ( Count , Sum , Average etc ) . The obvious way is to transform it to an IObservable with the method ToObservable , and then subscribe an observer to it . I noticed that this is much slower than oth... | Why is IEnumerable.ToObservable so slow ? |
C_sharp : I have : How I make it , as MyBook to inherit the top-level Book namespace , instead of Company 's ? <code> namespace Book { ... } ... ... namespace Company { public class Book { } ... ... ... ... ... ... public class MyBook : Book.smth { } } | When same-named namespaces exist ( in current scope ) , how to refer any of them ? |
C_sharp : I have a working solution for WP8.0 . But I needed to upgrade to get access to WNS . I have succeeded in adding WNS to the upgrade solution in the main menu works . But after Upgrading to wp8.1 ( silverlight ) , I have had some weird errors , that only happens on runtime . As an example it happens in the foll... | xaml parse error on interaction triggers wp8.1 ( silverlight ) |
C_sharp : what 's the difference for the following two ways to define namespace ? in some where I may have Both need to do the same to use class AA by using A.B.C ; Can I use C.AA a ; to specify the AA class in C namespace or I have to use the fall namespace convention : A.B.C.AA a ; to avoid possbile confliction ? <co... | C # namespace questions |
C_sharp : I 'm trying to create an extension VSPackage for VS2017 ( in C # ) which would convert binary data to XML , opens that in the default VS XML editor and XML language service , and then converts it back to binary upon saving.However , I have troubles to line out which steps would be required for this . I though... | VSX : How can I reuse the existing XML editor to handle binary files converted to XML ? |
C_sharp : I have a byte array that looks something like this : My end goal is to split this array into sub array 's anytime I see the sequence { 0x13 , 0x10 } . So my desired result on the example array would be : Ideally , I would also need to know that the final array , { 0x75 , 0x3a , 0x13 } , did not end with the s... | How to properly search and parse an array using a sequence of elements as the target |
C_sharp : I 'm in a situation where two calls at the same time write to the session ( of an asp.net core application running on the old framework ) , and one of the session variables gets overwritten.Given the following controller code , assume that the long session gets called first , 200 ms later the short session ge... | ASP.NET session is overwritten |
C_sharp : I 'm slowly getting my head around delegates , in that the signature of the delegate must match that of the method it is delegating too.However , please review the following code . I am now stumped at this point , because the delegate returns void ( as that is what SaveToDatabase ( ) is ) but , it 's clearly ... | How does the keyword delegate work compared to creating a delegate |
C_sharp : Hello I 'm try to remove special characters from user inputs . At the end I 'm turning it back to a string . My code only removes one special character in the string . Does anyone have any suggestions on a easier way instead <code> public void fd ( ) { string output = `` '' ; string input = Console.ReadLine (... | Special characters Regex |
C_sharp : From https : //msdn.microsoft.com/en-us/library/d5x73970.aspx When applying the where T : class constraint , avoid the == and ! = operators on the type parameter because these operators will test for reference identity only , not for value equality . This is the case even if these operators are overloaded in ... | C # generic types equality operator |
C_sharp : How would I get change this snippet to correctly add an instance of A to a List < A > , B to a List < B > , etc . ? The exception is thrown because , while the Add ( ) is found by the binder , it passes in dynamic which fails overload resolution . I prefer not to change the above to use reflection , or at lea... | How to add a T to List < T > where List < T > masquerades as 'dynamic ' and T as 'object ' ? |
C_sharp : To my surprise I have discovered a powerful feature today . Since it looks too good to be true I want to make sure that it is not just working due to some weird coincidence.I have always thought that when my p/invoke ( to c/c++ library ) call expects a ( callback ) function pointer , I would have to pass a de... | Delegate on instance method passed by P/Invoke |
C_sharp : Is there a way in C # to disable keyword 's functionality in code ? In my case I want to define one of my enum items as float which obviously makes Visual Studio a bit confused : ) <code> public enum ValidationType { email , number , float , range } | C # disable keyword functionality |
C_sharp : What does = > means ? Here 's a code snap : <code> Dispatcher.BeginInvoke ( ( Action ) ( ( ) = > { trace.Add ( response ) ; } ) ) ; | What does '= > ' mean ? |
C_sharp : I have the below method where I need to check for some certain strings which could be in any case and then remove them . Just wondered if there was a better performing way ? <code> private void MyMethod ( string Filter ) { //need to remove < Filter > and < /Filter > case in-sensitive var result = Filter.ToLow... | Out of curiosity - is there a better performing approach to do this string replace ? |
C_sharp : Can anyone think of good Resharper pattern that will detect the following bug : I 've tried creating a pattern but I ca n't work out how to quickly handle all types of arithmetic ( e.g . + , - , * etc ) , and any nullable type ( e.g . Nullable < int > , Nullable < decimal > , Nullable < double > etc ) . Also ... | Resharper pattern to detect arithmetic with nullable types |
C_sharp : This is homework ! ! ! Please do not interpret this as me asking for someone to code for me.My Program : http : //pastebin.com/SZP2dS8D This is my first OOP . The program works just fine without user input ( UI ) , but the implementation of it renders my design partially ineffective . I am not using a List co... | C # : Bad design of class ( first OOP ) |
C_sharp : In my BL ( will be a public API ) , I am using ICollection as the return types in my Find methods , like : Note the use of ICollection instead of Collection < > .Now in my GUI , I need to cast the results back to Collection , like : This is because I need to use some Collection < > specific methods on my retu... | Question regarding return types with collections |
C_sharp : I have the following in my controller ; This only occurs 4 times but it bugs me that I have the code repeated 4 times.I then have a BaseController that then grabs the parameters and does stuff with them ; I 'd like to be able to do away with the Post ActionResult 's and have a single one in a base controller ... | Create common ActionResult |
C_sharp : tl ; dr : Overriding a generic iterator method in a constructed derived class results in a BadImageFormatException being thrown when compiled with Visual Studio 2010 ( VS2010 ) , regardless of .NET version ( 2.0 , 3.0 , 3.5 or 4 ) , platform or configuration . The problem is not reproducible in Visual Studio ... | Overriding generic iterator results in BadImageFormatException when compiled with Visual Studio 2010 |
C_sharp : I 've considered 2 cases : Ideone : http : //ideone.com/F8QwHYand : Ideone : http : //ideone.com/hDTcxXThe question is why does order of fields actually matter ? Is there any reason for this or it 's just simply because it is ( such is the design ) .If the reason is just that anonymus types are not supposed t... | Why does compiler generate different classes for anonymous types if the order of fields is different |
C_sharp : The following is a simplified version of the problem I 'm having : The comments are the values from the watch window in Visual Studio 2017However if I enter : in the watch window , I get : So how come I can cast it in the watch window and it works , but if I do it in the code it evaluates to null ? <code> var... | Casting object to IEnumerable < object > |
C_sharp : i ca n't understand the difference between a simple bare and I know I can use it only if i have a +1 overloaded ctor , but I ca n't understand the advantages of defining the parameterless constructor this way . <code> Public ClassName ( ) { } Public ClassName ( ) : this ( null ) { } | When and why should I use ClassName : this ( null ) ? |
C_sharp : Simplified , i have these 2 Extension method : And here is where i use them : I have more GetString ( ) extensions.My try { ... } catch { ... } is getting large and basically i search for ways to shorten it down to 1 catch that calls the extension based on the type of the exception.Is there a way to call the ... | Calling extension method 's overload with derived type |
C_sharp : While removing some obsolete code I came across an unexpected scenario , recreated below : Based in the output it seems that functions deprecated with a warning are permitted to call functions deprecated with an error and the code will execute . My expectation was that I would see a compiler error complaining... | Deprecation behavior using the [ Obsolete ] attribute |
C_sharp : EDIT : see my update below on my stance on Null in C # 8.0 before giving me options to patterns and suchOriginal questionI am trying to upgrade my base libraries to be `` null enabled '' , aka using the C # 8.0 < Nullable > enable < /Nullable > flag.When trying to work with abstractions , and in specific gene... | Generics and Nullable ( class vs struct ) |
C_sharp : When calling a method with a ref or out parameter , you have to specify the appropriate keyword when you call the method . I understand that from a style and code quality standpoint ( as explained here for example ) , but I 'm curious whether there is also a technical need for the keywords to be specified in ... | Is there a technical reason for requiring the `` out '' and `` ref '' keywords at the caller ? |
C_sharp : Could someone point out why this could be happening : I am using NHibernate and the Linq provider for it.The code that fails is listed here : Debugging shows that sequence ( which is an IQueryable < T > ) after this contains 2 elements , which were added to the database.I expect the first Where statement to y... | C # strange lambda behavior |
C_sharp : I am using Xamarin.Forms and I have 2 pages , one is a List View , the other is a just a view I am using as a filter for the List View . I am currently using Navigation.PushAsync to display this page , my question is , is there away to present it like a side menu ? I know there is Master Detail View which I a... | Xamarin.Forms Navigation.PushAsync as Side Menu |
C_sharp : I am using the debugger to step through my code . The code file I ’ m in has usings at the top , including for exampleIn Visual Studio 2008 this used to apply to the Watch window while debugging , so I could use extension methods such as .First ( ) and .ToArray ( ) in the watch window.For some reason , this h... | Watch window stopped accepting some usings |
C_sharp : The following code does n't compile ( error CS0123 : No overload for 'System.Convert.ToString ( object ) ' matches delegate 'System.Converter < T , string > ' ) : however , this does : In c # 4 , co/contra-variant delegates can be assigned to each other , and delegates can be created from co/contra-variant me... | How is method group overload resolution different to method call overload resolution ? |
C_sharp : I have csv file with 30 000 lines . I have to select many values based on many conditions , so insted of many loops and `` if 's '' i decided to use linq . I have written class to read csv . It implements IEnumerable to be used with linq . This is my enumerator : It 's working , but it 's slow . Let 's say i ... | Is possible to change search method in LINQ ? |
C_sharp : When im passing Bmp as stream , function always return , but file saving on disk correctly.When I load bpm from disk , function return correct MD5 . Also passing `` new Bitmap ( int x , int y ) ; '' with different value return same MD5.Why its happening ? Can somebody explain this strange behaviour ? <code> D... | Problem with counting MD5 from bitmap stream C # |
C_sharp : I 've got the following situation : There are two related types . For this question , I 'll use the following simple types : So that one Person might have multiple Accounts ( i.e. , multiple Accounts would reference the same PersonId ) .In our database , there are tens of thousands of persons , and each have ... | Retrieving large amount of records under multiple limitations , without causing an out-of-memory exception |
C_sharp : Suppose I have the following : In what situation ( s ) would there be an advantage to using MyClassB over MyClassA ? <code> public class MyElement { } [ Serializable ] [ StructLayout ( LayoutKind.Sequential ) ] struct ArrayElement { internal MyElement Element ; } public class MyClass { internal MyElement Comp... | When to use an array of a value type containing a reference types over an array of a reference type ? |
C_sharp : Given the following C # code : The question is : what is causing the type of i to be correctly inferred as an int ? This is not at all obviuous , as array2D is a rectangular array . It does not implement IEnumerable < int > . It also implements a GetEnumerator ( ) method , which returns a System.Collections.I... | Why does foreach ( var i in array2D ) work on multidimensional arrays ? |
C_sharp : is it possible to differ the variable I 'm assigning to depending on a condition ? The issue I came across is wanting to do this : Instead ofWhich results in the following error Error CS0131 The left-hand side of an assignment must be a variable , property or indexerSo I was wondering if there was a way to do... | Is there a way to use a ternary operator - or similar method - for picking the variable to assign to ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.