text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : Entity Framework Core introduced the methods HasServiceTier and HasPerformanceLevel to change the edition of an Azure SQL server . You can use them in OnModelCreating like this : If you use Add-Migration Add-Migration you get a migration like this : This seems to work fine but when I try to apply this migrati... | Specify Azure SQL server edition in EF Core without breaking local development |
C_sharp : I have the exact situation described in this question : Device Hub communication with printer queueDue to the question having neither an accepted , nor an acceptable answer , I am asking the question again.I have configured DeviceHub with Acumatica , and my printer is shown . I am sending the print job via a ... | Printer fails to receive job from DeviceHub |
C_sharp : I have the following ActionLink : yet when I hover over the link , the url displayed in the browser is http : //localhost:44334/Upload . Where is the controller in this url ? Strangely , clicking the url takes me to my File/Upload view , and yet stranger , the url displayed in the browser 's address bar is ht... | I 'm seeing strange ActionLink behaviour , why is the url displayed in the browser not displaying the seemingly correct controller ? |
C_sharp : I have the feeling I 'm not looking at this issue from the right angle here , and I 'm just not thinking of other solution.Assuming this generic class ; It is used to define `` ports '' in a graph-node editor . A port can transfer a object/value from one node to another , but they also need to be `` type-safe... | Invoking generic method/delegate from a non-generic base class |
C_sharp : I need some help . I am creating a SelectItem class like this : I would like the following code to be validInstead of having to do this : How can I accomplish this ? <code> public class SelectItem < T > where T : class { public bool IsChecked { get ; set ; } public T Item { get ; set ; } } SelectItem < String... | Implicit operator ? |
C_sharp : I hit a bizarre problem earlier which I have replicated in a new console application . I wonder , can anyone explain why this occurs ? You get an error on the DoSomething line : Error 1 The call is ambiguous between the following methods or properties : 'DoSomething ( int ? ) ' and 'DoSomething ( MyEnum ) ' H... | Can anyone explain this interesting C # problem ? |
C_sharp : Imagine the code above being used in the following case : It looks like it 's perfectly safe to inline y , but it 's actually not . This inconsistency in the language itself is counter-intuitive and is plain dangerous . Most programmers would simply inline y , but you 'd actually end up with an integer overfl... | Integral type promotion inconsistency |
C_sharp : BackgroundOur site is a press site and is viewed by many people around the globe . Obviously this means that we will be localising the site in as many languages as possible . A professional translator will be hired for each language.How our site works currentlyThe way we have planned to do this is by storing ... | Does the way we translate our website result in performance issues ? |
C_sharp : I 'm writing a desktop application in C # that should be able to access all users on a Google Apps `` account '' an retrieve calendar-events for each user . I have added the Calendar API and the Admin SDK to my `` project '' .Both methods ( below ) works fine on their own but when I want to authorize my app f... | Multiple Google access permissions for a desktop application |
C_sharp : I 've been struggling a lot lately to find decent solution which has authentication mechanism for server and client API's.I put alot of effort trying to find working ( ! ) code samples , but could n't find any.The code from DotNetOpenAuth does n't work for me - im using vs 2010 .net 4 webformAnyway , I ca n't... | OpenID API for both asp.net and JavaScript support ? |
C_sharp : List < T > derives from the following interfaces : I just wonder , why it needs all these interfaces ( in the class declaration ) ? IList itself already derives from ICollection < T > , IEnumerable < T > und IEnumerable.So why is the following not enough ? I hope you can solve my confusion . <code> public cla... | Why does List < T > implement so many interfaces ? |
C_sharp : I have following LINQ statement and I want to rewrite it using extension methods.One possible solution is : However this is everything but elegant . Do you any idea how to improve beauty of second expression ? <code> from x in efrom y in efrom z in eselect new { x , z } e.Join ( e , x = > 42 , y = > 42 , ( x ... | What 's elegant way to rewrite following LINQ statement using extension methods ? |
C_sharp : I 'm finding that ValueTuples evaluate differently when I access their properties from a collection.Why do these two highlighted lines evaluate differently and how can I change `` MyList [ 0 ] .c '' to get the value correctly ? <code> public static List < Tuple < string , bool > > MyTupleList = new List < Tup... | Why does the Visual Studio watch window show wrong values for ValueTuples in a collection ? |
C_sharp : I have two functions that have different enough logic but pretty much the same exception handling : It is not possible to use a single entry point for DoIt1 and DoIt2 , because they are called in from outside.Is Copy/Pase ( for the exception block ) the best approach ? <code> public void DoIt1 // DoIt2 has di... | What is the best way to re-use exception handling logic in C # ? |
C_sharp : I am developing a WinRT app using XAML and MVVM Light . This app is meant to make it easier to do data collection while the users are out in the field . I have a section of my app where users will need to enter in a bunch of information about several different items . These items are defined as classes that i... | Multiple input forms with same xaml file and different DataContexts |
C_sharp : I 'm creating a reusable library that targets several platforms ( .NET 4.0 , .NET 4.5 , .NETStandard 1.0 and .NETStandard 1.3 ) . The .NET 4.5 version of this project contains some features that are not available under the .NET 4.0 version . The unit test project that references this library project has one s... | How to let a Visual Studio 2015 xproject ( project.json ) reference the highest framework of a depending project |
C_sharp : I have a class called Message which overloads these operators : I want the == and ! = operators keep comparing references of the types other than String and Message but , gives me this : The call is ambiguous between the following methods or properties : 'Message.operator == ( Message , Message ) ' and 'Messa... | Overloading == operator for null |
C_sharp : I have came across this question : What does the [ Flags ] Enum Attribute mean in C # ? And one thing I have been wondering , using the accepted answer 's example , what will happen if I declare : Will the following steps in that example resulting an error ? If no , how can I get to MyColors.Red ? <code> [ Fl... | What happens if we declare [ Flags ] enum in order ? |
C_sharp : My OM has a 'product ' object.Each product has a 'manufacturer id ' ( property , integer ) .When I have a list of products to display , the first three are displayed as the 'featured products'.The list is already sorted in a specific sort order , putting the 'featured ' products first in the list . However , ... | LINQ Sorting - First three need to be different manufacturers |
C_sharp : This is a very uncommon problem and there are definetly many workarounds , but I would like to understand what is actually going on and why it 's not working.So I have 3 assemblies in a test solution , first assembly has type ClassA : Second assembly references first assembly and has ClassB : which has an exp... | Explicit cast operator fails with `` assembly is not referenced '' error |
C_sharp : I have a x64 crash dump of a managed ( C # ) application that p/invokes to native code . The dump was taken after the native code attempted to dereference a bad memory location , and after the .NET marshaler had turned it into an AccessViolationException . As a result , the stack frame where the error occurre... | How do I retrieve Register Context from AccessViolationException ? |
C_sharp : A part of my ( C # 3.0 .NET 3.5 ) application requires several lists of strings to be maintained . I declare them , unsurprisingly , as List < string > and everything works , which is nice.The strings in these Lists are actually ( and always ) Fund IDs . I 'm wondering if it might be more intention-revealing ... | Are there drawbacks to creating a class that encapsulates Generic Collection ? |
C_sharp : I have the following code snippet in C # : It 's running fine , but I am not getting the result I expect.Actual result9,9,9Expected result1,4,9Why am I not getting the result I expect ? <code> var actions = new List < Func < int > > ( ) ; IEnumerable < int > values = new List < int > { 1 , 2 , 3 } ; foreach (... | Why am I getting wrong results when calling Func < int > ? |
C_sharp : I am working with ComboBox elements that often contain very large quantities of data ; ~250000 data entries.This works fine when a ComboBox is set up a little like this.However , some custom modifications of the ComboBox I am working with require the ComboBoxItem elements to not be focusable . I achieved this... | None focusable ComboBoxItem |
C_sharp : I want to capture the selected date on my DropDown list , where there are five days will display on DropdownList.I 'm usually putting the default value on DropDown , but not this time because in the drop down list I want it always display the current date and the next five days . But I do n't know how to capt... | Capture a value from a dropdownlist where the display dropdownlist is not default |
C_sharp : I am using an asp.net webapi controller , and in my project I have a dll that I built myself . The dll is being used to validate if the person that the user is typing in actually exists.Here is my controller method : Now the two conditional statements above that have EmpData.. EmpData is from my dll.Here is t... | AJAX error not returning jqXHR.responseText.modelState when using custom dll |
C_sharp : Okay I have a derived class that has an overload to a method that 's on my base class . I call what I think would match the method signature of the base class but instead my derived classes implementation is called . ( The code below always prints out `` MyDerived '' ) Why is this ? <code> public class MyBase... | Compiler picking the wrong overload |
C_sharp : I am trying to call IEnumerable.Contains ( ) with a dynamic argument , but I am getting the error 'IEnumerable ' does not contain a definition for 'Contains ' and the best extension method overload 'Queryable.Contains ( IQueryable , TSource ) ' has some invalid argumentsI 've noticed that I can either cast th... | Why do I need to cast a dynamic object when calling IEnumerable.Contains ( ) ? |
C_sharp : Just wondering why Enumerable.Range implements IDisposable.I understand why IEnumerator < T > does , but IEnumerable < T > does n't require it . ( I discovered this while playing with my .Memoise ( ) implementation , which has statement like in its `` source finished '' method that I had placed a breakpoint o... | Why does Enumerable.Range Implement IDisposable ? |
C_sharp : Is there way to do something along these lines ? I do n't care about the type of the properties , I just need the properties to be available . This does n't have to be implemented with an interface , just using that as an example . <code> interface Iface { [ anytype ] Prop1 { get ; } [ anytype ] Prop2 { get ;... | C # Interface without static typing |
C_sharp : I 've got something like this : I have to make SomeDataBlob public so that it can be used as a member of the public interface method ExternalPlugin.DoStuff . However , I would not like to allow clients to inherit from that class and thus be susceptible to the brittle base class problem . ( All derivatives of ... | Can I disallow other assemblies from inheriting from a class ? |
C_sharp : I am migrating a project from .Net 4.6.2 into .Net Core 2.0 . What is the replacement for RoleProvider in Net Core ? The type or namespace name 'RoleProvider ' could not be found ( are you missing a using directive or an assembly reference ? ) New code looks like this , received errorUpdate : Answer from John... | Net Core : Type or namespace name 'RoleProvider ' could not be found |
C_sharp : In this threadHow to get null instead of the KeyNotFoundException accessing Dictionary value by key ? in my own answer I used explicit interface implementation to change the basic dictionary indexer behaviour not to throw KeyNotFoundException if the key was not present in the dictionary ( since it was convini... | Is there a built-in generic interface with covariant type parameter returned by an indexer ? |
C_sharp : The issue I 'm currently facing is that I 'm unable to get my C # program to write the file I want to send in the response ( I 'm writing the bytes of the file ) and have a valid HTTP response , the browser I 'm testing it with is saying ERR_INVALID_HTTP_RESPONSE if I have appended the file to the response.Or... | C # How do you send a file via TCP for HTTP ? |
C_sharp : I have found huge amounts of information ( ie , this ) on how to handle unexpected errors in ASP.NET , using the Page_Error and Application_Error methods as well as the customErrors directive in Web.config.However , my question is what is the best way to handle EXPECTED errors . For example , I have a page to... | Displaying expected errors to users in ASP.NET |
C_sharp : I 've got a DataGridView that is backed by a SortableBindingList as described by this article.This is essentially a BindingList whose Data source is a list of custom objects . The underlying custom objects are updated programatically.My SortableBindingList allows me to sort each column in Ascending or Descend... | Keeping a DataGridView autosorted |
C_sharp : I have a generic class which could use a generic OrderBy argumentthe class is as followsThe orderBy could be of various typese.g . The goal is to make the orderBy an argument rather than bake it inany ideas ? <code> class abc < T > where T : myType { public abc ( ... .. , orderBy_Argument ) { ... } void someM... | Linq and order by |
C_sharp : Given the following C # code : And its counterpart in VB.NET : It appears that VB.NET is able to correctly infer type of a = Object ( ) , while C # complains until the above is fixed to : Is there a way to auto-infer type in C # for the above scenario ? EDIT : Interesting observation after playing with differ... | Type inference in C # not working ? |
C_sharp : I came across the following code , all in a single file/class . I 'm leaving out the details , its the construct I 'm interested in . Why are there two different declarations for the same class and how are they different ? What 's the purpose of the syntax for the second declaration ? <code> public abstract c... | What is this C # construct doing and why ? MyClass < TMyClass > : MyClass where |
C_sharp : First time poster here , but I have been using stackoverflow this entire quarter to help me along in my intro to C # class . Generally , I can find what I 'm looking for if I look hard enough , but I have been unable to find anyone that has already answered my question.I have an assignment that wants me to di... | How to properly align a 5x10 2-d array with random data in console ? |
C_sharp : This is the first time I face a problem like this . Not being this my profession but only my hobby , I have no previous references.In my program I have added one by one several functions to control a machine . After I added the last function ( temperature measurement ) , I have started experiencing problems o... | Multithreading or something different |
C_sharp : I 'm forwarding type definitions for our legacy support . I 'm using following syntax to do so : problem I 'm having is that I ca n't find correct syntax for generic type definitions ( it should be possible based on Eric Lippert 's post and many other places ) .What I would expect as working solution isAny id... | Forward generic type definition |
C_sharp : I have a vertically and horizontally scrollable DataGridView on a form.I use virtual mode because the underlying datatable is huge.When I scroll right , if the last column is not fully shown in the view , then I see repeated calls to CellValueNeeded.How can I fix this ? My thoughts : Why is CellValueNeed bein... | Repeated calls to CellValueNeeded |
C_sharp : I am trying to serialize a List to a file in C # with JSON.NET.I want to be able to add values to the list and serialize that change.I do not want to serialize the list all over again , since it can grow pretty big.Is something like that possible with JSON.NET ? this way it would only be possible to `` Reseri... | continuous serialization of a list with JSON.NET |
C_sharp : Here 's the Lambda expression I am using to try and include the User table , which throws an error.The include statement gives this error The Include path expression must refer to a navigation property defined on the type . Use dotted paths for reference navigation properties and the Select operator for colle... | Include Derived Models Related Class |
C_sharp : What I want to do is combine lambda syntax with `` params '' to carry out an action on a series of object.Let 's say I want to make a bunch of controls invisible.After a bit of fiddling I ended up with an extension method : and then I can create an action : and then call it : This is n't very nice syntax thou... | C # syntax for applying an action to a varying number of objects |
C_sharp : I have the follwoing code and I would like to write it in a way that I have minimum lines of code and the work is done the same way . How can I do that ? <code> List < Category > categoryList = new List < Category > ( ) ; categoryList = Category.LoadForProject ( project.ID ) .ToList ( ) ; List < string > cate... | How can I avoid code duplication |
C_sharp : I am reading some x and y coordinates from an XML file.The coordinates look like this 3.47 , -1.54 , .. and so on.When I assign the value to a double variable byThe Value becomes 3470.00Why is this the case ? <code> double x , y ; x = Convert.ToDouble ( reader [ `` X '' ] ) ; // X Value : 3.47 | Why does Convert.ToDouble change my Value by factor 1000 ? |
C_sharp : I want to create a copy my object in my DB with using Entity Frameworkfirst I got my `` Book '' from DBthen , I tried to add this object as a new objectAlso I trid to initilize EntityKey of Bookit didnt workIs there any way doing this without creating new Book and copy properties from old one ? Thanks <code> ... | How to Add existing entity as a new Entity with Entity Framework |
C_sharp : I am converting a codebase to C # 8 with nullable reference types . I came across the a method similar to the one in this question but async.T may be any type , including nullable reference types or nullable value types.To be clear , I understand WHY this method triggers a warning . What I 'd like to know is ... | Proper nullable annotation for async generic method that may return default ( T ) |
C_sharp : The BackgroundI have converted the C # code below ( found in TreeViewAdv file TreeColumn.cs ) into VB.net code using the converter found at DeveloperFusion.com . C # VBThe ProblemAccess to TreeColumn.TreeColumnConverter in this line of the C # code is fine . [ TypeConverter ( typeof ( TreeColumn.TreeColumnCon... | `` Private '' visibility modifier - how to handle differences when converting C # to VB ? |
C_sharp : What I basically wish to do is design a generic interface that , when implemented , results in a class that can behave exactly like T , except that it has some additional functionality . Here is an example of what I 'm talking about : And this is all well and good , but in order to use CoolInt , I need to do ... | C # Interfaces : Is it possible to refer to the type that implements the interface within the interface itself ? |
C_sharp : To my surprise , this one compiles and runs : The method is public whereas the default value `` redirects '' to a constant private variable.My question : What is/was the idea behind this `` concept '' ? My understanding ( until today ) was , that something public can only be used if all other `` referenced ''... | What 's the idea behind allowing private constant to be used as default parameters for public methods ? |
C_sharp : What happens if I pass a data member by reference to a function , and while that function is running , the Garbage Collector starts running and moves the object containing the data member in memory ? How does the CLR make sure reference parameters do n't become invalid during Garbage Collection ? Are they adj... | passing data members by reference |
C_sharp : I have a little C # problem . I have two classes ClassA and ClassB defined in this way : As you can see , ClassA has an instance of ClassB.The thing is , from a list of ClassA instances , I want to access to a list of the corresponding ClassB instances . I suppose it would look like this : The solution is pro... | Class associations and lists |
C_sharp : I was browsing the source of the PluralizationService when I noticed something odd . In the class there are a couple of private dictionaries reflecting different pluralisation rules . For example : What are the groups of four dashes in the strings ? I did not them see handled in the code , so they 're not som... | What are the groups of four dashes in the .NET reference source code ? |
C_sharp : Is there a mechanism for the new c # 8 using statement to work without a local variable ? Given ScopeSomething ( ) returns a IDisposable ( or null ) ... Previously : However in C # 8 with the using statement , it requires a variable name : The _ here is not treated as a discard.I would have expected this to h... | using statement in C # 8 without a variable |
C_sharp : What happens when I add a method to existing delegate ? I mean when I added the method1 to del , del holds the address of method1 . When I add method2 afterwards , del still points to Method1 and Method 2 address is inserted on the bottom of it . Does n't this mean I changed the delegate ? If I can change thi... | Delegates are immutable but how ? |
C_sharp : I 'm running into a problem where as I have an implied unsigned hexadecimal number as a string , provided from user input , that needs to be converted into a BigInteger.Thanks to the signed nature of a BigInteger any input where the highest order bit is set ( 0x8 / 1000b ) the resulting number is treated as n... | What is the proper way to construct a BigInteger from an implied unsigned hexadecimal string ? |
C_sharp : In my WPF application I have a sort of node graph . I have added a ContextMenu to these nodes , which appears when I right-click on stuff and so on.The commands in the context menu come from a Service ( Microsoft.Practices.ServiceLocation.ServiceLocator ) with DelegateCommands , and those commands are updated... | RaiseCanExecuteChanged delay with ContextMenu |
C_sharp : I am trying to write the following : I would like to write a method `` A '' which takes as parameter another method `` B '' as well as an unknown number of parameters for this method B . ( params object [ ] args ) . Now , inside method A i would like to make a call to B with the parameters args . B will now r... | C # Method that executes a given Method |
C_sharp : I was surprised that there would be any runtime difference between these two delegates ( fn1 and fn2 ) : But apparently the second lambda is treated like an instance method , because its Target property is non-null . And it was treated differently before I switched to Visual Studio 2015 ( in VS2012 , I am pre... | Lambda treated as a closed delegate in Roslyn |
C_sharp : When running We see a difference when using different framework versions.vsAlso why would I see different a NumberFormat.CurrencyPositivePattern between machines . Is it framework specific or related to the OS ? 40,00 kr . vs kr . 20,00 <code> var x = 10.0M ; Console.WriteLine ( typeof ( Program ) .Assembly.I... | What controls the CurrencyPositivePattern in .NET |
C_sharp : I want to create a wrapper around this existing helper : How can I create a helper to wrap this and add a parameter to it ? My Controller has a property : I want to somehow reference this value from my controller and use it like : How can I do this ? Is the only way to add IsAdmin to my ViewModel ? <code> @ C... | How to create a wrapper helper around Url.Content helper function ? |
C_sharp : I have static e paper but i want to develop dynamic e-paper like below urlhttps : //epaper.dawn.com/ ? page=15_04_2019_001I have no idea to start e paper dynamic below is my whole html codei am not getting any idea to implement dynamic , i have to take repeater control or grid view control to achieve dynamic ... | Trying to make epaper dynamic using C # asp.net web form |
C_sharp : I do n't understand why it 's working ... The IL code : It compiles to bool Object.Equals ( Object , Object ) , but why ? <code> class Program { static void Main ( string [ ] args ) { IComparable.Equals ( 12 , 3 ) ; } } .method private hidebysig static void Main ( string [ ] args ) cil managed { .entrypoint /... | IComparable magic - why it 's a valid statement ? |
C_sharp : why does n't the element get swappedeven if the parameter is without a ref modifier the array does n't change.a copy of the reference is passed as a parameter right ? <code> public static void SwapArray ( int [ , ] arr ) { for ( int i = 0 ; i < arr.GetLength ( 0 ) ; i++ ) { for ( int j = 0 ; j < arr.GetLength... | basic c # question |
C_sharp : I am going through the Head First C # book and I ca n't figure out why they used the following way to create a property . It just seems inconsistent with the convention I 'm seeing everywhere else and in the book itself too . I understand that the pattern for creating properties is : Based on the above patter... | Head First C # : strange way to create a read-only property |
C_sharp : I have an application where you can select between different objects in a ListBox . When you select an object , it changes the viewmodel for a control . The control utlizes the Timeline Control from CodePlex , and because of this , I have the StartDate and EndDate for the timeline data bound to ViewModel . Wh... | OnPropertyChange Firing Order |
C_sharp : Is this kind of if-testing necessary when removing an item ? And , what about this test ? <code> if ( _items.Contains ( item ) ) { _items.Remove ( item ) ; } if ( ! _items.Contains ( item ) ) { _items.Add ( item ) ; } | C # List < T > Contains test |
C_sharp : The code below is part of authorization . I am trying to mentally imaging what it actually does but could not somehow . Could anyone explain this lambda expression to me ? Thanks ! Edit : IsAuthorized is a delegate type . The previous programmer who code this seems want to keep it secret by putting delegate t... | Could anyone explain this lambda expression to me ? It 's kind getting me crazy |
C_sharp : Like there are many Applications which are just basic but you can have install add-ins for it which extends its functionality in that Application . For example : How do they design such applications and how does the application accept the module and how can it automatically integrate.Secondly I do not know if... | Designing Application that can accept add ins |
C_sharp : I 've simple Linq2Sql query : The problem is that it seems that new SomeLinq2SqlEntity ( ) is executed only once for the sequence , so all instances of MyViewModelClass in result of the query share the link to one object.Update : Here is how I quickly check it : Using debugger I can check that MyField was set... | `` new '' inside concrete type projection is only called once |
C_sharp : Does Linq use any sorting or other mechanisms to make a group join more efficient so it does n't have to loop through an entire collection for every unmatched item ? In other words , Is this : more efficient than this : <code> var x = listA.GroupJoin ( listB , a = > a.prop , b = > b.prop , ( a , b ) = > new {... | Efficiency of Linq GroupJoin vs. Linq All in Select |
C_sharp : We 've got a slight performance issue in a section of code that 's using LINQ and it 's raised a question about how LINQ works in terms of lookupsMy question is this ( please note that I have changed all the code so this is an indicative example of the code , not the real scenario ) : GivenIf I had a list of ... | Does this LINQ code perform multiple lookups on the original data ? |
C_sharp : Suppose we had the following : I am using Autofac to register all of my components that implement IFoo : When I later resolve my dependencies with : I should get all of the classes that implement IFoo except the contract class ( es ) . How do I prevent all of my contract classes from resolving without moving ... | Autofac and Contract classes |
C_sharp : Here is my code which is used widely in project , and I 'm wondering can I refactor this somehow so I might avoid == null checks all the time ? Thanks guysCheers <code> ActiveCompany = admin.Company == null ? false : admin.Company.Active | How could I avoid == null checking ? |
C_sharp : I have a simple object that looks like this : I tried this code I found somewhere on the net : But somehow the returning byte array has a size of 248 bytes.I would expect it to be 4 bytes x 4 fields = 16 bytes.QUESTION : What 's the cleanest way to convert a fixed object into a byte array ? And should the res... | Fixed Object to Byte Array |
C_sharp : Consider the following code ( for the sake of this test , it does n't do anything of particular use - it 's just to demonstrate the error that occurs ) I want to wrap Dictionary < string , dynamic > using inheritance : Here is the examle above using this derived class : This happens ... Any ideas on what is c... | C # compilation error with LINQ and dynamic inheritance |
C_sharp : I have the following code : and when I run the test `` TestFoo ( ) '' , the console output is `` Foo - string '' . How does the compiler decide which method to call ? <code> [ TestMethod ] public void TestFoo ( ) { Foo ( null ) ; } private void Foo ( object bar ) { Console.WriteLine ( `` Foo - object '' ) ; }... | How does the compiler choose which method to call when a parameter type is ambiguous ? |
C_sharp : Basically , is it better practice to store a value into a variable at the first run through , or to continually use the value ? The code will explain it better : or <code> TextWriter tw = null ; if ( ! File.Exists ( ConfigurationManager.AppSettings [ `` LoggingFile '' ] ) ) { // ... tw = File.CreateText ( Con... | Read a value multiple times or store as a variable first time round ? |
C_sharp : I have the following code in my .Net 4 app : This givens me an ensures unproven warning at compile time : What is going on ? This works fine if S is an integer . It also works if I change the Ensure to S == Contract.OldValue ( S + `` 1 '' ) , but that 's not what I want to do . <code> static void Main ( strin... | Why is this string-based Contract.Ensure call unproven ? |
C_sharp : i have a path data that i coppy it from syncfusion program.i have a path with that data in my page and want to animate my object exact on path way ( in mid of path line ) but the problem is the object move on outline ( surroundings ) of path .here is code : Edit 1 : my animation go wrong way . i want my Recta... | MatrixAnimationUsingPath animate on surroundings ( outline ) of path |
C_sharp : I have been working a little bit with LINQ recently , and thanks to the help of some StackOverflowers I was able to get this statement working : However , I am confused because the piece that makes it work is the if ( traceJob.Count ( ) ==1 ) . If I remove that section , then I get an ObjectNullRef error sayi... | Why does an IF Statement effect the outcome of my LINQ Statement ? |
C_sharp : I have this simple LINQ query , which executes for 8395 ms : Its IL : when it executes , it generates the following SQL query , which takes 661 ms to execute : What was Entity Framework ( version= '' 6.1.0.133 '' ) doing all that time ? Little change to the LINQ query , namely removing ToString ( ) call in th... | Why does ToString ( ) degrade Entity Framework 's performance so dramatically |
C_sharp : Why ca n't I use code like this ? 12And should write like this12PS : I can use if-else statement without { } . Why should I use them with try-catch ( -finally ) statement ? Is there any meaningful reason ? Is it only because that some people think that code is hard to read ? Several months ago I asked that qu... | Why does it not allowed to use try-catch statement without { } ? |
C_sharp : Possible Duplicate : “ new ” keyword in property declaration Pardon me if this is C # 101 , but I am trying to understand the code below : Why does the indexer have new in front of it ? By the way , Rabbit is a class defined in another file . Thanks ! <code> using System ; using System.Collections.Generic ; u... | Why does this code have new in the collections indexer |
C_sharp : Specifically , if you create an instance of a Timer in the local scope , and then return from that scope:1 ) Will the timer still execute ? 2 ) When would it be garbage collected ? I offer these two scenarios : And <code> Timer timer = new Timer ( new TimerCallback ( ( state ) = > { doSomething ( ) ; } ) ) ; ... | What is the expected behavior of a locally scoped Timer ? |
C_sharp : I 'm stuck with a weird problem ( which is probably my lack of knowledge ) , I present the offending code : f and fTemp are FileInfo objects . So if I run this with code where f is a video file playing in a mediaplayer it throws the exception . That works fine and as expected . Now when I close the mediaplaye... | Delete functions deletes even when calling app is closed |
C_sharp : I 've this piece of code : If I build my application in Debug mode everything is ok , test index pre prints 12 and test index post prints 14. the same in Release mode with Optimize code unchecked . if i test with Optimize code checked test index post prints 18 instead of 14.Same result if I replace index += e... | RyuJIT C # wrong sum result with /optimize |
C_sharp : Why is it when I turn on `` check for arithmetic underflow/overflow '' under C # Project Properties > Build > Advanced , that the following code runs faster ( 138 ms ) than if I turn the option off ( 141 ms ) ? Test Run # 1 : 138ms with checked arithmetic , 141ms withoutOn the other hand , if you comment out ... | Why is checked arithmetic in .NET sometimes faster than unckecked ? |
C_sharp : Let 's say you wrote a custom enumerator for the code below : And then in the client code , you did this : Then , set a break-point on the MoveNext method implementation of your StudentEnumerator class.Then when you run the code and the debugger breaks after constructing the query / IEnumerable in this case ,... | How does Visual Studio evaluate the IEnumerable without breaking into its IEnumerator < T > 's MoveNext ? |
C_sharp : Consider these two definitions for GetWindowText . One uses a string for the buffer , the other uses a StringBuilder instead : Here 's how you call them : They both seem to work correctly whether I pass in a string , or a StringBuilder . However , all the examples I 've seen use the StringBuilder variant . Ev... | For C # , is there a down-side to using 'string ' instead of 'StringBuilder ' when calling Win32 functions such as GetWindowText ? |
C_sharp : I have discovered that if i run following lines of code.No boxing is done , but if i call i.GetType ( ) ( another derived function from System.Object ) in place of GetHashCode ( ) , a boxing will be required to call GetType ( ) , Why its not possible to call GetType ( ) on primitive type instance directly , w... | Why calling some functions of the Object class , on a primitive type instance , need boxing ? |
C_sharp : As I do n't know how my problem is called , I can not guarantee , that nobody has asked the same question recently or at all.I did notice , however that there are quite a few threads with a similar title , but they do n't seem to be relevant to my problem.I have a custom list class , that implements Generics.... | About Generics and Inheritance ( forgive my bad title ) |
C_sharp : The following is a code snippet about covariance in C # . I have some understanding about how to apply covariance , but there is some detailed technical stuff that I have hard time grasping.Invoking IExtract < object > .Extract ( ) invokes IExtract < string > .Extract ( ) , as evidenced by the output . While ... | C # covariance confusion |
C_sharp : I have a troublesome query to write . I 'm currently writing some nasty for loops to solve it , but I 'm curious to know if Linq can do it for me.I have : and a list that contains these structs . Let 's say it 's ordered this way : If you put the orderedList struct dates in a set they will always be contiguou... | How can I use `` Linq to Objects '' to put a set of contiguous dates in one group ? |
C_sharp : I have a .dll and a console app that uses the said .dll but does n't reference directly , it loads it via reflection . The console app calls a method of a class inside the .dll.The method signature is IEnumerable < Customer > GetAll ( ) ; In the .dll I have done this : In the Console app I 've done this : Now... | Access to type T properties of IEnumerable < T > returned from a method called via reflection |
C_sharp : The following codeThrows a run-time KeyNotFoundException , albeit that { 1 } is a perfectly well-formed array ( i.e . int [ ] a = { 1,2,3,4 } being valid code ) . Changing the TValue of the Dictionary to int [ ] , throws a compile-time CS1061 , but this does not ( note the added new [ ] array-allocation ) : W... | Reason for KeyNotFoundException in Dictionary initialization |
C_sharp : Do I need to add a lock block here if I want to be sure that instance will be created only 1 time ? Since there is only 1 instruction within the IF I 'm not 100 % sure . In a case like below , I 'm sure I 'd need it but I wanted to double check if the same applies for the code above.EDITYes , I assume multith... | Do I need a lock here ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.