text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I 'm refactoring a little bit of C # data access code from a previous developer and am curious about a pattern he used.The code initially exposed collections ( arrays ) of a variety of ActiveRecord-style business objects - essentially objects wrapping database fields . I 'm changing the arrays to generic list... | Any advantage to objects.GetObject ( i ) over objects [ i ] ? |
C_sharp : As a learning exercise , I 'm trying to reproduce an async/await deadlock that occurs in a normal windows form , but using a console app . I was hoping the code below would cause this to happen , and indeed it does . But the deadlock also happens unexpectedly when using await.I 'm mostly curious if anyone kno... | async/await deadlock when using WindowsFormsSynchronizationContext in a console app |
C_sharp : If I have a method like thisis f created every time SomeMethod is called ? I mean , does that line take time to compute or does the compiler store the function somewhere on compile time skips it at execution ? <code> void SomeMethod ( ) { Func < A , B > f = a = > /*Some code*/ ; ... b = f ( a ) ; } | Inline lambda function creation behaviour in C # |
C_sharp : Consider this simple .js code : // UsageI 'm pretty sure c # support first class function , note that I do n't want to use classes to remake the code above . What is the equivalent closure in c # ? I have made this : <code> const createCounter = ( ) = > { let value = 0 ; return { increment : ( ) = > { value +... | What is the equivalent javascript closure in c # ? |
C_sharp : Firstly , This might seem like a long question . I do n't think it is ... The code is just an overview of what I 'm currently doing . It does n't feel right , so I am looking for constructive criticism and warnings for pitfalls and suggestions of what I can do.I have a database with business objects.I need to... | Overly accessible and incredibly resource hungry relationships between business objects . How can I fix this ? |
C_sharp : I have the following two button click methods that create an array from three TextBoxes , order the values , insert them into a database and then select the values in the same order . The only difference between the two buttons is that one orders the values in ascending order and the other in descending order... | Structuring button click methods to avoid code repetition |
C_sharp : Possible Duplicates : What does placing a @ in front of a C # variable name do ? What ’ s the use/meaning of the @ character in variable names in C # ? As you can imagine , Googling or Binging for any phrase containing an ' @ ' is difficult.In creating a new web service , one of the members of the imported C ... | What is the purpose of @ as part of a member name in C # ? |
C_sharp : On the internet I see a lot of code which uses this . to access local members of a class , like this : ( do n't expect the code to do something sensible . I just wanted to show a few different uses for `` this . `` ) I wonder why to do this ? To add more clarity to the source ? Or is it just a waste of space ... | Use this . to access internal class members ? |
C_sharp : I 'm gettin an error pointing to in in the foreach loop ! ? Has never happens before . What could be the reason for this ? Have I missed something ? Error message : An exception of type 'System.NotSupportedException ' occurred in EntityFramework.SqlServer.dll but was not handled in user code Additional inform... | Foreach loop error |
C_sharp : Similar to how lambda expressions with free variables work I would like to implement my own closure class that captures some method parameter.Then I have some class that works with DateTime instances . One of the methods that should use this closure class is this : I would like to convert it to use Closure cl... | Storing pointer to method parameter for later reuse |
C_sharp : I 've seen this piece of code from one of the jetbrain 's team : Looking at this code : Question : What is the scope of the lock ? <code> object myLock = new object ( ) public IEnumerable < int > Values ( ) { lock ( myLock ) { for ( var i=0 ; i < 10 ; i++ ) yield return i ; } } public void Test ( ) { foreach ... | What is the scope of the lock ? |
C_sharp : How can I have a type reference that refers to any object that implements a set of interfaces ? For example , I can have a generic type like this : Java : C # That 's how to have a class-wide generic type . However , I 'd like to simply have a data member which references any object that extends a given set o... | C # - How can I have an type that references any object which implements a set of Interfaces ? |
C_sharp : So I 'm making a tile based game and I 'd like to add some fake shadows to the tiles . It 's kinda hard to explain so I 'll do it with pictures : Let 's say this is my tile world : And I want it to have shadows like this : Because the world is tile based , I can split all the shadow parts into separate images... | How would I efficiently make fake tile shadows ? |
C_sharp : Code : Two identical blocks in identical usings . Output : Second block takes 2.2 seconds ! But if to get rid of usings , durations became same ( ~0.3s , like first one ) .I 've tried with .net framework 4.5 and .net core 1.1 , in release , results are same.Can anybody explain that behavior ? <code> internal ... | What is the reason of so different durations of same code blocks execution ? |
C_sharp : I 'm struggling with implementing the IEquatable < > interface for a class . The class has a Parameter property that uses a generic type . Basically the class definition is like this : In the Equals ( ) method I 'm using EqualityComparer < T > .Default.Equals ( Parameter , other.Parameter ) to compare the pro... | How to compare two IEnumerable < T > in C # if I do n't know the actual object type ? |
C_sharp : This loads a set of values from an XML file and places them into a class for storage . I 'm trying to figure out how to output the values as a list so I can place them into a Listbox.I thought there would be an easy way like a .ToList ( ) method or to be able to foreach through the strings in the class ( no p... | Outputting Class Of Stored Values To List |
C_sharp : My understanding is that x is not actually declared as a variable eg . var x = 3 . Instead , it 's passed into the outer function , which returns a function that returns the original value . At the time it is returning this , it creates a closure around x to remember its value . Then later on , if you alter s... | Is this an example of a closure in C # ? |
C_sharp : There are two ways to implement overloads . The first one is to do everything in one method/constructor and call it from other overloads , which leads to longer method bodies . The second one is to do the minimum in each overload , thus having a code sometimes difficult to navigate and to understand which ove... | How to choose between one big method with passive overloads and a bunch of small overloads , each one doing a small amount of work ? |
C_sharp : Is this possible in C # ? The following code produces a compiler error.The C # compiler complains , `` Error CS0149 : Method name expected . '' It 's unable to infer the lambda method 's return type.Note my technique of invoking the lambda method immediately via the ( ) after the the lambda block is closed { ... | Assign C # Async Lambda Method to Variable Typed as a Task |
C_sharp : When I run my C # application , Visual Studio reports that it has loaded a managed binary with ( what looks like ) a randomly generated name . For example : or : What is this , and why is its name ( seemingly ) randomly generated ? <code> 'WindowsFormsApplication1.vshost.exe ' ( Managed ) : Loaded 'ehmgcsw7 '... | When I run my C # application , Visual Studio reports that it has loaded a managed binary with ( what looks like ) a randomly generated name |
C_sharp : I 'm using string.Join to be able to show what values an array contains . I have stumbled upon a strange behavior when using a byte array and startIndex and count.gives this resultWhole byteArr : 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8Whole stringArr : 1 , 2 , 3 , 4 , 5 , 6 , 7 , 80 - 5 byteArr : System.Byte [ ] , 0 , ... | Strange behavior of string.Join on byte array and startIndex , count |
C_sharp : I 'm making a WPF text-editor using TextFormatter . I need to justify the last line in each paragraph . Something like that : how to make this happen ? Thanks in advance ! ! <code> I need to justify the last line in eachparagraph I need to justify the last line in each paragraph I need to justify the last lin... | Full justify of last line in WPF TextFormatter |
C_sharp : is that an `` ok '' code ? I need to do complex operation in the finally and it might crash since it 's connecting to the a DBthis look weird to me , so . is this the proper way ? <code> try { /*stuff*/ } catch ( Exception e ) { /*stuff*/ } finally { try { /*stuff*/ } catch { /*empty*/ } } | is it ok to have a try/catch in a finally ? |
C_sharp : Currently , I have a bunch of classes of this form that I 'd like to create at runtime using Reflection.Emit . However , I 'm running into an issue when I attempt to add the parent - since the TestAdmin class does n't exist before runtime , I do n't know how to create Any ideas ? <code> [ Name ( `` Admin '' )... | Using emitted type as type parameter in Reflection.Emit |
C_sharp : I have a few days looking at RX , and I have read a lot ; I have read IntroToRx ; I have also looked at 101 RX Samples , and many other places , but I ca n't figure this out . It sounds so simple , but I ca n't get what I need : I need to know which `` ID '' has been `` stuck '' in state 'STARTED ' for at lea... | Using RX queries , how to get which records have same status for a window of 3 seconds every second ? |
C_sharp : I 'm writing a translator , not as any serious project , just for fun and to become a bit more familiar with regular expressions . From the code below I think you can work out where I 'm going with this ( cheezburger anyone ? ) .I 'm using a dictionary which uses a list of regular expressions as the keys and ... | Determining which pattern matched using Regex.Matches |
C_sharp : I have created a method for reading inbox new messages by using exchange server like below.How to add these IEnumerable collection to a Queue and Process each List of item inside the queue asynchronously ? The below are the process i need to call asynchronously by using each items in the queue <code> private ... | How to add an IEumerable Collection to a Queue and Process each item asynchronously in .NET ? |
C_sharp : I have a simple .NET application which runs as Windows Service . Say it has one Class I want to create a console application where I would type simple human readable commandslike Pretty much like you do in windows console . I wonder what is the best way to implement this mapping . A straight methods is of cou... | Scripting .NET objects |
C_sharp : I am using string builder to format my string to append and prepend white spaces at the start and end of the stringhere is what I have so far : but I 'm getting the error incorrect format . What am i doing wrong ? <code> private void button1_Click ( object sender , EventArgs e ) { String Word = textBox1.Text ... | Inserting user defined number of spaces before and after string using C # |
C_sharp : I am currently migrating a project to PostSharp to remove a lot of boilerplate code , most of it is going very smoothly but I 'm left confused about how to force a command to recheck if it CanExecute . I expected PostSharp would inspect the command like it does properties to check for dependencies , here is a... | Triggering `` CanExecute '' on postsharp [ Command ] when a document changes ? |
C_sharp : I work an an automation team designing tests for electronic components . One thing our framework sorely needs is a single source point for our driver objects for the various pieces of test equipment at a workbench ( right now , driver object creation is very wild-west ) . Basically , the idea would be there w... | Is this method returning a System.Object class an anti-pattern ? |
C_sharp : I have the following class : When I try to find out size of this class on a 64 bit system by using WinDbg I get the size 40which I am not able to understand , as far as I have read MyClass should haveI do n't have 10 reputation that 's why i am not able to post image.Anyone has any idea why WinDbg is showing ... | How to determine size of an object , c # ? |
C_sharp : Short Question : Provided I have given an implicit conversion mechanism for my object to convert its values from a plain string , can it be made to auto-bind to ViewModel 's property ? Details : I have a complex object like so ( simplified for brevity and clarity ) I am using the above object in my view model... | Can a QueryString parameter be bound to a complex object if the complex object has implicit casting from string |
C_sharp : I 'm looking to add a `` recently opened '' functionality to my application , and was wondering if there was a simple built in way to do lists that `` overflow '' . By this I mean , when you add an element beyond the capacity of the list , all the items are shifted.Code example of desired functionality ( obvi... | Does .NET have a simple way to do overflow lists ? |
C_sharp : I have a database table that looks like this : Now . This is a Status History indicator for DetectorID 1541.I only want to show 1 row at my website . To do this i excecute the following query.So what it does , it grabs the newest row ( Based on TimeStamp ) , and shows it.This will give me the results of Scann... | C # Query Select first since value changed |
C_sharp : I have to deserialize a response from an api which has the following structure : Some insights : The JSON is an array of objectsEvery object inside the array will ALWAYS have the properties `` starttime '' and `` endtime '' Objects `` var1 '' , `` var2 '' , `` var3 '' will ALWAYS have the same properties insi... | How to deserialize JSON with dynamic and static key names in C # |
C_sharp : I 'm inheriting from TextBox and overriding OnInit . I have MyBase.OnInit ( e ) in the example above , but I 've been using my control for a while without it , as I forgot to put it in there . This is something I usually do out of habit , so I never gave its purpose much thought : When overriding OnInit in a ... | What 's the impact of not using MyBase.OnInit ( e ) when overriding it in a derived class ? |
C_sharp : I have an MVC application which has a restful service that updates latitude and longitude to the database . I am sending the values to the API as string and its converted to Double before it is stored in database as Double . Here is the code I am using to convert string to double : When its stored in database... | Double is not stored correctly in MySQL database |
C_sharp : I 'm trying to figure out how to define if string contains/does not contains list value and if contains but with other value . If I have input string : and I want find specific value for condition : But not sure what is a proper way if I want to know also about third condition , if string contains value but a... | How to check if string contains list value and separately if contains but with other value |
C_sharp : I 'm inheriting the code someone else wrote at work and found that there are a lot of `` new '' instantiating without actually assigning to a variable : I 'm just wondering if anyone has any experience with this and if this is anti-pattern or not . <code> new MyCoolClass ( ) .MyCoolMethod ( ) ; | Instantiating without assigning to a variable |
C_sharp : What is the difference in autofac between these two registrations : andwhere Instance is a ( non-static ) property of an autofac module in which the registration occurs , set by object initializer.My reason for asking is that the former has been done in a piece of code I 'm debugging and I 'm getting some str... | What is the difference between these two ways of registering an instance in autofac |
C_sharp : Given the following LinqPad example : Why can EnumerableMethod take the list directly while ListMethod needs a cast first ? I get that an cast is happening from DbItem to IDbItem , but what is different about the IEnumerable that allows it to make the cast without an express request ? I imagine the answer inv... | Why does IEnumerable not need a cast but a List does ? |
C_sharp : So here is my problem , I have an API setup that returns results from Azure Storage Table in JSON string format : And I am trying to convert it back to Project object : I keep getting `` Error converting value from 'string ' to 'object'.I have tried : this , this , this , this , this , this and this and it wo... | Converting from json to List < object > causing exception |
C_sharp : Assuming we have the following model : And the following implementation : Now my question : Is codesnippet # 1 equivalent to codesnippet # 2 ? Or does it take longer to run codesnippet # 1 ? CodeSnippet # 1 : CodeSnippet # 2 : <code> public class Father { public Child Child { get ; set ; } public string Name ... | Is the C # or JIT compiler smart enough to handle this ? |
C_sharp : I have a FlipView in my MainPage . It 's ItemTemplate binded to a UserControl called landscapeControl . It 's ItemsSource is binded to a List of a class called MyLandscape . landscapeControl : MyLandscape class : My images are showing perfectly . All I want is 3 things:1 ) I want to access my Canvas from my M... | Access a Canvas inside an ItemsSource in a UserControl , from the MainPage |
C_sharp : There 's a subtle point about assembly dependencies I would like to understand . I have a project which uses SharpDX through a custom wrapper like so : SharpDX.dll < - Wrapper.dll < - Project.dllIn Wrapper.dll is a type such as : In this class , if I uncomment the commented constructor , then Project.dll must... | Why does an unused constructor cause an assembly dependency in this case ? |
C_sharp : In my form I have four RadioButtons , based on user selection , this code is executed : The code seems very redundant and repeated , but also I ca n't find a way to handle all 4 RadioButtons in a single line that has only one variable linked to user choice.myList is a List of a class I created that has 4 stri... | Best way to handle redundant code that has repeated logic ? |
C_sharp : I do n't understand why code first does not add a new item to the collection until after calling savechanges . I installed EF4.1 from NuGet ( 4.1.10331.0 ) . I created the following example : First I added one record to the database . Then I ran this and these are the results : My questions are : - Why does t... | EF4 code first adding items not very clear to me |
C_sharp : Just ca n't get it with datepicker validation.I have datepicker From and datepicker To , so I want to prevent the user from doing some kung fu and seting datepicker From to be bigger than datepicker To , I 've bumped across some questions but could n't find the answer , so I 've tried doing the easiest way I ... | Proper way for datepickers validaton in c # ? ( windows forms ) |
C_sharp : AKA why does this test fail ? <code> [ TestFixture ] public class Tests { [ Test ] public void InnerClassShouldBePublic ( ) { Assert.IsTrue ( typeof ( InnerClass ) .IsPublic ) ; } public class InnerClass { } } | Why are inner class not public when viewed in reflection ? |
C_sharp : Why , when I turn INT value to bytes and to ASCII and back , I get another value ? Example : <code> var asciiStr = new string ( Encoding.ASCII.GetChars ( BitConverter.GetBytes ( 2000 ) ) ) ; var intVal = BitConverter.ToInt32 ( Encoding.ASCII.GetBytes ( asciiStr ) , 0 ) ; Console.WriteLine ( intVal ) ; // Resu... | Why do I get a different value after turning an integer into ASCII and then back to an integer ? |
C_sharp : I 'm writing code that calls the following method that exists in Windows.Networking.PushNotificationsI want to be sure to cover all cases where exceptions can be thrown and deal with each appropriately . Is it possible for me to get a list of the different types of exceptions this can throw and different circ... | How can I find out what kind of exceptions can be thrown by a method ? |
C_sharp : I would like to write custom SQL code for mysql and mssql ( perhaps more later ) .The Problem starts here . I would like to declare the connection via an interface or abstract-class before the if-statement . But it seems not possible , because the command-classes demand explicitly the specific SqlConnection o... | Abstractionlayer for Database-Access |
C_sharp : Initializing a class like this : I am getting an InvalidCastException on one of the assignments . There are quite a lot of them and the exception occurs on the whole expression even if I run the debugger line-by-line . The exception does n't give any clue either what it 's trying to cast to what.Is there a wa... | Is it possible to debug a struct/class initialization member by member ? |
C_sharp : I 'm a bit puzzled here ... I have a test method which does a call to an async method and I changed the signature to async Task . Works.Now I read all over the web that support for async is required in unit tests and is now also in NUnit . But why is that so important ? I can write the test like this , using ... | Why would one need `` async '' support for MS Unit Test if Task.Result can be used ? |
C_sharp : Ok so I am trying to get all the Companies assigned to BOTH courses that exist in a course mapping table.The course mapping table has 2 FK CourseIDs , that point to two different courses in the same table.Each course has a bundle , and the companies are assigned to bundles.I am trying to select all the compan... | Can anyone reduce these 3 LINQ to SQL statements into one ? |
C_sharp : I 'm reading Jon Skeet 's C # in Depth.On page 156 he has an example , Listing 5.13 `` Capturing multiple variable instantiations with multiple delegates '' .In the explanation after this listing , he says `` each of the delegate instances has captured a different variable in this case . `` I understand this ... | In closure , what triggers a new instance of the captured variable ? |
C_sharp : So , I am writing this school project that should be some basic chat program that consists of a client and a server . I am trying to handle either the server or the client programs being closed.So when you press the big red X in the Client window , this is what happens : It sends a message to the server infor... | C # Socket programming , closing windows |
C_sharp : I was trying to understand the answer for this question Why am I getting wrong results when calling Func < int > ? I wrote some sample code . The following code produces After reading the explanation by Jon Skeet and Eric Lippert I thought I will get Here both v and i are loop variables , while the value of i... | why this C # program outputs such a result ? How do I understand closure ? |
C_sharp : I want to make a list of pointers to locations that contains a certain value in the process memory of another process . The value can be a short , int , long , string , bool or something else . My idea is to use Generics for this . I have one problem with making it , how can I tell the compiler to what type h... | Compare byte [ ] to T |
C_sharp : I have a many-to-many relationship between tables of Games and Genres . During an analysis , i need to get items from Games that match specific criteria.The problem is , to check for this criteria , i need to analyse genres of this specific game . And linq wo n't let me do it.My request now looks like this : ... | Nested .Select ( ) inside of .Where ( ) |
C_sharp : I have a struct that holds a single object field to make working with the object easier . I wanted to test the performance ( I expected some degradation ) , but I get very surprising results . The version with the struct actually is faster : Without box : 8.08 sWith box : 7.76 sHow is this possible ? Below is... | How can a struct with a single object field be faster than a raw object ? |
C_sharp : I 'm trying to create a string extension method with the following signature : I 'm getting a compiler error : Default parameter value for 'provider ' must be a compile-time constantCould n't find anything on google and my only work around is to do this : Anyone know how I can set the default value of IFormat... | Provide compile-time constant for IFormatProvider |
C_sharp : I have a line of code that is giving me an warning message ( CS0675 ) in VS2015 , but not in 2013 . Warning CS0675 Bitwise-or operator used on a sign-extended operand ; consider casting to a smaller unsigned type first . The compiler implicitly widened and sign-extended a variable , and then used the resultin... | Bug in compiler or misunderstanding ? Or operator on shorts |
C_sharp : I have a similar problem to the post Accessing a static property of a child in a parent method . The preferred answer hints that the design of the classes is faulty and more information is needed to discuss the problem . Here is the situation I want to discuss with you.I want to implement some unit aware data... | Accessing a static property of a child in a parent method - Design considerations |
C_sharp : I 'm refactoring a number of classes in an application to use interfaces instead of base classes . Here 's the interfaces I created so far : ICarryable implemented by all Item objects IActable implemented by all Actor objectsIUseable implemented by some Item sub-classesIWieldable implemented by some Item sub-... | Need help choosing a name for an interface |
C_sharp : Is there a difference betweenAND ? If so , what ? Are n't they both just pointers to methods ? <code> Object.Event += new System.EventHandler ( EventHandler ) ; Object.Event -= new System.EventHandler ( EventHandler ) ; Object.Event += EventHandler ; Object.Event -= EventHandler ; | Wiring EventHandlers |
C_sharp : I have the following code that attempts to catch a null reference . It then throws an exception with a clearer reason for the error specified in the message property . What type of exception should it throw ? An IndexOutOfRangeException ? or a NullReferenceException ? or , should we have just let the exceptio... | IndexNotFoundException versus NullReferenceException |
C_sharp : I 'm developing an app that connects with WCF service to load data . I added a Web Service Reference directly from Visual Studio , and runs very well.But , my problem now is this : I have to connect with different WCF services depending the user who login app.Exists any way to doing this by code ? ? I 'm usin... | Multiple WCF connections in Xamarin Forms |
C_sharp : I have an MVC application with EF6 . Is there a way to automatically set all properties of a model to [ Required ] ? Some of our models are large with all required fields . Any way to save lines of code or make this cleaner ? Thanks <code> public class Employee { [ Required ] public string Name { get ; set ; ... | MVC model require all fields |
C_sharp : I know we can escape curly bracket in C # using { { and } } . But they do n't seem to work well if they are right after a format modifier ( like { 0 : F6 } ) . <code> string str ; // Prints `` { 3.14 } '' as expectedstr = string.Format ( `` { { { 0 } } } '' , 3.14 ) ; Console.WriteLine ( str ) ; // Expected `... | C # escape curly bracket not working with format modifier ? |
C_sharp : I 'm looking for a way to implement something like this : Of course , I could define a conditional compilation symbol by myself , but it is n't suitable.Is there any built-in constant ? The questions I found are rather old . Maybe , the things were changed to the best ? <code> # if CSHARP_COMPILER_IS_FOR_CSHA... | Conditional compilation depending on compiler version |
C_sharp : I have Kendo charts drawn on a page and I am posting their image data to an action to save this base64 encoded data to a ( SQL Server ) database . Here is the exportImage call in which I first split the base64 data from the dataURL : My Export_TargetPrice method is essentially just a call to Convert.FromBase6... | FromBase64String fails with Kendo charts |
C_sharp : I came across this code in which a variable is assigned to itself for no good reason.It is not making much sense to me . Is there a reason behind this ? <code> double x = x = ( a - b ) / ( c - 1 ) ; | What is the purpose of this : `` double x = x = ( a - b ) / ( c - 1 ) ; '' |
C_sharp : I wonder if there is a way of writing a method or a class that would add to any method some code that is shared between many methods . The methods return different things and some of them are just void.Below is a part of the code that is duplicated in the methods.Any help would be greatly appreciated.Nix solu... | Is there a way of using one method to handle others to avoid code duplication ? |
C_sharp : I have the controller method GetLayer2 ( ) . It is extremely similar to GetLayer0 ( ) and GetLayer1 ( ) The code can be summed up as : Get the OrgCodeGet and parse the datePassedIn to the processDateUrlDecode the driverIdExecute a stored proc , putting the output in resultsConvert results to Json ( This was a... | MVC JsonResult has data , but browser has none |
C_sharp : In .Net , is there a way to convert , say , ' 2:45 ' to the decimal 2.75 ? ex : It should throw an exception if invalid data , ex , minutes < 0 < 60 or not in the h : m format.Thanks <code> decimal d = TimeToDecimal ( `` 2:45 '' ) ; Console.WriteLine ( d ) ; //output is 2.75 | Parse time string to decimal ? |
C_sharp : These two statements look the same logically to me , but they 're resulting in different SQL being generated : Example # 1 does n't work , but example # 2 does.The generated SQL for the var people query is identical for both , but the SQL in the final query differs like this : Why is there this difference ? E... | What 's the difference between these two LINQtoSQL statements ? |
C_sharp : I 'm interpreting an exception report from a C # Windows Phone app . A method throws a NullReferenceException . The method goes : It 's consistent with m_Field being null - there 's simply nothing else there that can possibly be null . But here 's the mysterious part.The GetILOffset ( ) from the StackFrame fr... | NullReferenceException vs. MSIL |
C_sharp : Trying to follow the hints laid out here , but she does n't mention how to handle it when your collection needs to return a value , like so : This obviously wo n't work , because dispatcher.BeginInvoke does n't return anything . What am I supposed to do ? <code> private delegate TValue DequeueDelegate ( ) ; p... | Returning objects from another thread ? |
C_sharp : Can we make a property of a class visible to public , but can only be modified by some specific classes ? for example , Child is a data class , Parent is a class that can modify data , Cat is a class that can only read data.Is there any way to implement such access control using Property in C # ? <code> // th... | how to implement selective property-visibility in c # ? |
C_sharp : Suppose I want to write an extension method to dump some data from a T [ , ] to a CSV : which I could call withbut suppose myData is a Complex [ , ] and I want to write the magnitude of the complex number , not the full value . It would be handy if I could write : but I 'm not sure how to implement that in th... | Lambda in C # extension method |
C_sharp : How is the below code is printing true ? I expected this to print False , because I expected two separate objects to be constructed and then their references compared . <code> string x = new string ( new char [ 0 ] ) ; string y = new string ( new char [ 0 ] ) ; Console.WriteLine ( object.ReferenceEquals ( x ,... | Object.ReferenceEquals prints true for two different objects |
C_sharp : I 'd like to know how best to program three different editions of my C # ASP.NET 3.5 application in VS2008 Professional ( which includes a web deployment project ) .I have a Light , Pro and Ultimate edition ( or version ) of my application.At the moment I 've put all in one solution with three build versions ... | How to program three editions Light , Pro , Ultimate in one solution |
C_sharp : After migrating to ASP.NET Core 2.1 we have realized that some consumers of our API are sending GET requests with the Content-Type header set to application/json . Sadly , these requests have not been rejected in the past ( even though they should have ) , nevertheless this still is a breaking change..Since o... | How to accept a bodyless GET request with JSON as it 's content type ? |
C_sharp : Considering the following : It is clear that you would say BudgetView extends ViewBase , and it implements IView , but what does it to to poor old Export ? Perhaps BudgetView uses Export ? Or BudgetView applies Export ? I need this for my documentation . I 'm need to be very formal and very detailed.Edit : My... | What verb would describe the relationship between a C # class and its Attribute ? |
C_sharp : If I have a model with a key of type Guid , is it bad practise to set the ID explicitly in the constructor ? I know it will be set implicitly by Entity Framework , but will anything bad happen ( perhaps performance wise ) from setting it explicitly ? Example : I 'm thinking a Guid is backed up by a sequential... | Is instantiating a GUID in Entity Framework Core bad practice ? |
C_sharp : I need to create a Type instance for an array of a base type with a specified number of indexes . Essentially I need to method like the following that I can call ... So that calling the function would give the following result ... The only solution I can come up with is the following ... This does work but ha... | How to get the Type that describes an array of a base type ? |
C_sharp : I need to distribute a set of data evenly over time based on historical data such that each digit appears an equal ( or close to equal ) number of times in each position over time . The problem is , given a list of orderings used in the past , that look like this ( but could have any number of elements ) : ho... | Finding the least-used permutation |
C_sharp : I have a code like this : We can notice some boring repetition in the code.So , it would be nice to write a generic method Update in a way we can afford ourselves to write something like this : Tell me , please , is it possible to write such a method ? Which book can I learn that from ? ( I have found only on... | How to define my own LINQ construct in C # ? |
C_sharp : suppose I have : processing may take a long time and while it was in the middle another packet has arrived . What happens next : the processing gets done and then another event is fired or perhaps new event is fired immediately but on a new thread ? <code> ethernet_adapter.PacketArrived += ( s , e ) = > { //l... | events and threading |
C_sharp : As I am developing my small game , I have made a lot of progress yet frustrated about a lot of things . The latest thing was creating a list of required items and for you to understand that I will provide you with both Explanation as well as Code which I created but obviously does n't work ... I - Explanation... | Creating a tree of required items |
C_sharp : I have function like this : Everything is good , except that it complains about return null ; part Can not convert expression type 'null ' to type 'T'How do I return null from function like this ? <code> private T DeserializeStream < T > ( Stream data ) where T : IExtensible { try { var returnObject = Seriali... | How do I return null from generic function ? |
C_sharp : I have a simple ViewComponent works correctly in the browser chrome and Firefox but do not work in a browser Edge \ IE 11.The component shows the time ( just for example ) .Chrome and firefox time is displayed.Edge Browser \ IE 11 , time is displayed only the first time the page is up and remains so , time is... | Rendering ViewComponent with ajax do n't work in Edge/IE11 |
C_sharp : I am using .net core 3.1 . With the help of docker I uploaded my code to heroku . but when i make a web request I get a 405 error with all my endpoints . ( I cant see more details of the error ) using Get : from visual studio code and also locally from my IIS everything works fine . but the problem occurs whe... | Deploy ASP.NET Core Docker project - get a 405 error ( locally in my IIS , web requests works ) . How to fix it ? |
C_sharp : The best way I can describe what I 'm trying to do is `` Nested DistinctBy '' .Let 's say I have a collection of objects . Each object contains a collection of nicknames.I want to select all Persons but make sure nobody selected shares a nickname with another . Molly and Steve both share the nickname 'Lefty '... | How Can I Achieve this Using LINQ ? |
C_sharp : I am working on some code which is something like this : Someclass contains the required constructor.The code for this compiles fine without any warning . But I get a code hazard in system : `` The Someclass ctor has been called from static constructor and/or static initialiser '' This code hazard part of sys... | Static variable initialization using new gives a code hazard |
C_sharp : This is a followup to this question : Why does a division result differ based on the cast type ? Quick Summary : The question is : Why are the results different depending on the cast type ? While working out an answer I ran into an issue I was n't able to explain.This outputs the following : Breaking it down ... | Why does a division result differ based on the cast type ? ( Followup ) |
C_sharp : I 'm working on a library that simplifies application configuration . Essentially , consumers of the library either decorate their configuration classes with attributes or they initialize the settings declaratively in code . It would be possible to specify 1 or more sources from which to read/write configurat... | Best practices for DI in a library involving Types in attributes |
C_sharp : I seem to be getting different results when filtering . I expect the same result from these two pieces of code : I am trying to find items which have the same name as my firstGuess.Method A works as expected , but B seems to give me a odd result in that ! matches2.any ( ) returns false , when I would expect t... | Why am I getting different results filtering with foreach vs LINQ .Where ( ) ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.