text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I was experimenting with the const modifier while exploring a plethora of C # tutorials , and placed a bunch of const modifiers in a class like this without actually using them anywhere : With this class , I get the following warning ( using csc ) : ConstTesting.cs ( 3,19 ) : warning CS0414 : The field ‘ Cons... | Confusing warning about a constant decimal field in C # |
C_sharp : Could Someone help me to clarify the difference between : I get the same results in both cases without knowing the difference .Does the Eager Loading require using Include ? <code> var query = awlt.People.Include ( p = > p.EmailAddresses ) .Where ( p = > p.LastName.Equals ( lastName ) ) .SelectMany ( a = > a.... | Using include does n't change the behavior |
C_sharp : I 've been doing some code refactoring in my C # projects.I got a Resharper code analysis warning : `` Redundant string interpolation '' This happens in following scenario : I 've read string interpolation is rewritten to string.Format at compile time . Then I tried following : This time I get : Redundant str... | Redundant string interpolation and performance |
C_sharp : I wrote a test program wherein a single Button is defined in XAML as the content of a Window . Upon the window 's loading , the Button is programmatically replaced as the window 's content , and the field referring to it is also replaced , both by another Button which I created programmatically . I thereafter... | XAML Button not garbage collected after eliminating references |
C_sharp : If you have a Form that displays data , one thing you can do is reference this.DesignMode in the constructor to avoid populating it in the designer : However , if you decide to re-write that form as a UserControl , keeping the same constructor logic , something unexpected happens - this.DesignMode is always f... | Are there any caveats to swapping out DesignMode for LicenseManager.UsageMode in a WinForms UserControl constructor ? |
C_sharp : Here is what I would like to do : Is such a construction possible in .NET ? Edit : The question was not clear enough . Here is what I want to do , expanded : Meaning , I want the constrained type to : - accept a single generic parameter - implement a given single generic parameter interface.Is that possible ?... | Can one specify on a generic type constraint that it must implement a generic type ? |
C_sharp : I may not have it correct , but I saw something like this above a WebMethod : I saw a vb version first and I used a converter to convert it to c # . I have never seen it before . It 's in a vb 6 asmx file . <code> [ return : ( XmlElement ( `` Class2 '' ) , IsNullable = false ) ] public Class2 MEthod1 ( ) { } | What does this syntax mean in c # ? |
C_sharp : I 'm using the Winforms WebBrowser control to collect the links of video clips from the site linked below.LINKBut , when I scroll element by element , I can not find the < video > tag.Soon after using theI already return 0Do I need to call any ajax ? <code> void webBrowser_DocumentCompleted_2 ( object sender ... | How to get an HtmlElement value inside Frames/IFrames ? |
C_sharp : I 've just rebuilt my machine with a fresh install of Visual Studio 2015 . I 've also installed the extensions for Web Essentials and Web Compiler but these seem to have caused a problemSay for example , prior to installing Web Essentials and Web Compiler , if I was editing a Razor view , if the current eleme... | Razor editor formatting not working after installing Web Essentials and Web Compiler |
C_sharp : I have a List < Fruit > , and the list above contains 30 Fruit objects of two types : Apple and Orange . 20 apples and 10 oranges.How can I get a list of 10 random fruits ( from the basket of 30 fruits ) , but there should be 3 oranges and 7 apples ? <code> public class Fruit { public string Name { get ; set ... | Get random items with fixed length of different types |
C_sharp : Here is a simple C # .NET Core 3.1 program that calls System.Numerics.Vector2.Normalize ( ) in a loop ( with identical input every call ) and prints out the resulting normalized vector : And here is the output of running that program on my computer ( truncated for brevity ) : So my question is , why does the ... | Why does the result of Vector2.Normalize ( ) change after calling it 34 times with identical inputs ? |
C_sharp : I 'm looking into solutions to convert a string into executeable code . My code is extremely slow and executes at 4.7 seconds . Is there any faster way of doing this ? String : `` 5 * 5 '' Output : 25The code : <code> class Program { static void Main ( string [ ] args ) { var value = `` 5 * 5 '' ; Stopwatch s... | Convert string to executable code performance |
C_sharp : One of my fellow developer has a code similar to the following snippetHere the Data class properties fetch the information from DB dynamically . When there is a need to save the Data to a file the developer creates an instance and fills the property using self assignment . Then finally calls a save . I tried ... | Is it ok to use C # Property like this |
C_sharp : I saw this kind of code at work : Any idea what does a static modifier on a constructor mean and why in this case it is required ? <code> class FooPlugin : IPlugin // IPlugin is a Microsoft CRM component , it has something special about it 's execution { static FooPlugin ( ) { SomeObject.StaticFunction ( ) ; ... | What does a static modifier on a constructor means ? |
C_sharp : I 'm using .NET 4.5 in a VSTO addin for outlook 2013 . I 'm having some trouble fully grasping properties and accessors . Auto-implemented accessors which I assume are when you just write get ; set ; rather than get { //code } , etc . are also giving me trouble . I have a dictionary I use internally in my cla... | Properties and auto-implementations |
C_sharp : I 'm trying to resolve CA2225 , which WARNs on ContrainedValue < T > below , with the following message : Provide a method named 'ToXXX ' or 'FromXXX ' as an alternate for operator 'ConstrainedValue < T > .implicit operator T ( ConstrainedValue < T > ) '.I 've also pasted PositiveInteger to illustrate a use-c... | How to fix CA2225 ( OperatorOverloadsHaveNamedAlternates ) when using generic class |
C_sharp : BackgroundEven though it 's possible to compile C # code at runtime , it 's impossible to include and run the generated code in the current scope . Instead all variables have to be passed as explicit parameters.Compared with dynamic programming languages like Python , one could never truly replicate the compl... | How to access locals through stack trace ? ( Mimicking dynamic scope ) |
C_sharp : I 'd like to know if it is possible to use an expression as a variable/parameter in C # . I would like to do something like this : Here 's what I do n't want to do : Really what I 'm getting at is a way to get around using a switch or series of if statements for each of : < > < = > = == ! = . Is there a way t... | C # : Is there a way to use expressions as a variable/parameter ? |
C_sharp : I am using Microsoft Interactivity and Microsoft Interactions to rotate an object based on a Property in my code-behind . To make the rotation more smooth I added in an easing function . It does the animation perfectly fine but when it reaches the end of the animation for 1 split frame the rotation resets to ... | Easing animation 'twitches ' when it finishes |
C_sharp : I would like to know the way to make a list of drop down lists in C # class . I have been trying like this : Then I add _ddlCollection to the Asp.NET site like this : But it breaks on line : Can you tell me how to add a few DDL 's to a List ? <code> List < DropDownList > _ddlCollection ; for ( int i = 0 ; i <... | How to make a list of DDL in C # programatically |
C_sharp : In the MSDN Events Tutorial hooking up to events is demonstrated with the example : Where as I have been keeping a reference to the delegate . Example : When I look at the MSDN example code , `` -= new '' just looks wrong to me . Why would this List have a reference to an event handler I just created ? Obviou... | How does the removing an event handler with -= work when a `` new '' event is specified |
C_sharp : I 'm using Entity Framework 6.1 , code-first . I 'm trying to store/retrieve a decimal from SQL Server , but the correct precision is n't retrieved . I read from a .csv file , process the data , then insert into the DB.Value in the .csv file : 1.1390Value when saved as decimal from the import : 1.1390Value in... | EF retrieves incorrect decimal precision |
C_sharp : I usually find myself doing something like : and I find all this mixup of types/interface a bit confusing and it tickles my potential performance problem antennae ( which I ignore until proven right , of course ) . Is this idiomatic and proper C # or is there a better alternative to avoid casting back and for... | When to use each of T [ ] , List < T > , IEnumerable < T > ? |
C_sharp : Recently it seems like Microsoft changed something in the behaviour when people are trying to sign-in with their Microsoft Account through our services.We have a setup where we use IdentityServer4 and Azure AD for the Microsoft Accounts . When people try to sign-in now , they just click sign-in button on our ... | IdentityServer4 and Azure AD auto selects users on sign-in page |
C_sharp : For some reason , with the Razor view engine , VS is crashing on me . I copied the CSHTML content over to a VBHTML file and begin reformatting it , and VS has crashed on me twice now as I change a helper or function method syntax from : toIs anyone else getting this ? The whole machine must be rebooted to get... | VS Crashes with RAZOR VBHTML |
C_sharp : Consider the following two alternatives of getting the higher number between currentPrice and 100 ... I raised this question because I was thinking about a context where the currentPrice variable could be edited by other threads.In the first case ... could price obtain a value lower than 100 ? I 'm thinking a... | Is the ternary operator ( ? : ) thread safe in C # ? |
C_sharp : Being new to programming I have only just found out that you can specifically catch certain types of errors and tie code to only that type of error . I 've been researching into the subject and I do n't quite understand the syntax e.g.I understand the InvalidCastException is the type of error being handled , ... | Being specific with Try / Catch |
C_sharp : What happens when a synchronous method is called within an asynchronous callback ? Example : A connection is accepted and the async receive callback is started . When the tcp connection receives data , it calls the receive callback . If the sync Send method is called , does that stop other async callbacks fro... | Call Sync method call from Async Callback ? |
C_sharp : I want lines as many as the width of the console to simultaneously write downwards one char to the height of the console . I 've done most of it , but it goes from top to bottom to right etc ... If you need help picturing what I mean , think of the matrix code rain . <code> int w = Console.WindowWidth ; int h... | How to write in multiple positions in a console application at the same time ? C # |
C_sharp : While working on a upgrade i happened to come across a code like this.My question is : Is there any need/use of 'explicit ' implementation of interface in this piece of code ? Will it create any problem if i remove the method ( explicit implementation of interface ) that i have marked `` redundant '' above ? ... | Implicit and Explicit implementation of interface |
C_sharp : I 'm trying to post FormData including both a File and a Collection.This is my Model : This is my action : My FormData in JavaScript is : And here is the header : The `` File '' is working fine , but the `` Content '' is always null.Where am I going wrong ? Thank you ! <code> public class Content { public str... | Collection always null when using [ FromForm ] attribute |
C_sharp : I have a huge list of Items and need to Group them by one property . Then the oldest of each group should be selected.Simplified Example : Select the oldest User of each FirstName.Class User : I was wondering why this statement took so long until I set a breakpoint at Result and looked into the SQL statement ... | Entity Framework GroupBy take the oldest with mySQL |
C_sharp : I created new Azure account and trying to automatically deploy app inside it with following code : It works , if identifierUrl is hardcoded as Azure Active Directory name.How can I read identifierUrl ( Azure Active Directory domain name ) from Azure ? I can see this value in portal , but I can not find an API... | How to read domain of Azure Active Directory |
C_sharp : Given this code : I would have expected ReflectedType to be SomeDerivedClass given that it is the type of the parameter for the expression . But it is SomeClass , which is - if i understand correctly - the declaring type . Why is that ? <code> static void Main ( string [ ] args ) { Expression < Func < SomeDer... | ReflectedType from MemberExpression |
C_sharp : I 'm developing a Windows Phone 8.1 app . I have a screen with a list of news ' titles with thumbnails . First I 'm making asynchronous http request to get news collection in JSON ( satisfying the NotifyTaskCompletion pattern ) NewsCategory : News : So far it works perfectly , but as soon as I get the ImagePa... | Async/await deadlock while downloading images |
C_sharp : I 'm having some problems setting up a command handling architecture . I want to be able to create a number of different commands derived from ICommand ; then , create a number of different command handlers derived from ICommandHandler ; Here 's the interface and classes I have begun to define : I have a help... | Contravariance ? Covariance ? What 's wrong with this generic architecture ... ? |
C_sharp : I am reviewing another developer 's code and he has written a lot of code for class level variables that is similar to the following : Does n't coding this way add unnecessary overhead since the variable is private ? Am I not considering a situation where this pattern of coding is required for private variabl... | Is there any benefit to declaring a private property with a getter and setter ? |
C_sharp : I have two pages say Page1 and page2.In Page-1 I have a listview and an Image button ( tap gesture ) .Here if I click listview item , it navigates to Page2 whereit plays a song.Song continues to play . Then I go back to page1 by clicking back button . Then as mentioned I have an imagebutton in page1 , if I cl... | Navigation in Xamarin.Forms |
C_sharp : I 've just found strange for me code in Jeffrey Richter book ( CLR via C # 4.0 , page 257 ) and have misunderstanding why it works so.Result : As you can see , we have an accessor property named 'Students ' , which has only getter ( not setter ! ) , but in 'Main ' function , when we 'd like to initialize 'cla... | get and set misunderstanding in initialisation : Jeffrey Richter , CLR via C # |
C_sharp : I am saving xml from .NET 's XElement . I 've been using the method ToString , but the formatting does n't look how I 'd like ( examples below ) . I 'd like at most two tags per line . How can I achieve that ? Saving XElement.Parse ( `` < a > < b > < c > one < /c > < c > two < /c > < /b > < b > three < c > fo... | Writing xml with at most two tags per line |
C_sharp : I connect to a 3rd party webservice that returns a complex JSON object that only contains a few bits of information I actually need.Basically , I just need the array in `` value '' . From that array , I just need the `` Id '' , `` Title '' and `` Status '' properties.I want to put those attributes into a c # ... | Selectively read part of JSON data using JsonSerializer and populate a c # object |
C_sharp : In C # , I can attach documentation for properties , methods , events , and so on , directly in the code using XML Documentation Comments . I know how to insert a reference to a particular method : Is there a way to insert a reference to a method group ? Where I 've got multiple overloads of the same method n... | In xml doc , can I insert a reference to a method group ? How ? |
C_sharp : I 'm trying to learn MVVM , but there is something I do n't understand yet.Currently , I have this event handler : Very easy . However , I would like to apply the MVVM pattern in this application.I 'm wondering , am I supposed to put this logic in a ViewModel instead of directly in the view code ? If so , how... | MVVM - Exit confirmation |
C_sharp : We have our integration tests set up using xUnit and Microsoft.AspNetCore.TestHost.TestServer to run tests against Web API running on ASP.NET Core 2.2.Our Web API is a single code base that would be deployed separately multiple times based on some configuration or application setting differences like country ... | Run single test against multiple configurations in Visual Studio |
C_sharp : If a type has no static constructor , field initializers will execute just prior to the type being used— or anytime earlier at the whim of the runtimeWhy this code : yields : while this code : yields The order of a and b is understood . but why dealing with static method is different than static field.I mean ... | static constructors and BeforeFieldInit ? |
C_sharp : It is quite a while that I have been trying to understand the idea behind IEnumerable and IEnumerator . I read all the questions and answers I could find over the net , and on StackOverflow in particular , but I am not satisfied . I got to the point where I understand how those interfaces should be used , but... | Why do we need two interfaces to enumerate a collection ? |
C_sharp : I have an array of { 0,1,2,3 } and want to shuffle it . This is working pretty wellsome of the time . However , I 'm finding that it often produces a stack of { 1,2,3,0 } where 0 is just placed on the back of the stack . In fact , often enough that this does n't appear random at all . An `` original sequence ... | ensuring a sequential stack of 3 does n't appear in a shuffled array of 4 ? |
C_sharp : I am new to GraphQL , when I try to upgrade .net core version from 2.2 to 3.0I got problem about UI display on /graphql page when using UseGraphiQlAPI is working normally but the UI is display incorrect.I googled for find out solutions , but nothing really helpful.Here is my config for graphql : Any help is g... | Upgrade GraphQL from .NET core 2.2 to 3.0 |
C_sharp : Been coding .net for years now yet I feel like a n00b . Why is the following code failing ? UpdateApproved the answer from CodeInChaos . Reason for the 16 bytes becomming 32 bytes can be read in his answer . Also stated in the answer : the default constructor of UTF8Encoding has error checking disabledIMHO th... | It sould be so obvious , but why does this fail ? |
C_sharp : I 'm navigating the ins and outs of ref returns , and am having trouble emitting a dynamic method which returns by ref.Handcrafted lambdas and existing methods work as expected : But emitting a dynamic method fails . Note : I 'm using Sigil here . Apologies , I 'm less familiar with System.Reflection.Emit.Thi... | How can I emit a dynamic method returning a ref ? |
C_sharp : I try to Delete a Row from the Database on the phpAdmin the Query is workingfine , but when I execute it with the Code : I get theError : Destination array is not long enough to copy all the items in the collection . Check array index and length.I Insert the to deleting user before without any trouble.The Dat... | MySqlException on ExecuteReader by Selecting UserID ( PK ) |
C_sharp : I have a DLL written in C # .NET which exposes a COM interface , so a vb6 application can call my DLL . This interface looks like : This works fine . But each time I build this DLL without changing the interface ( because I had to fix something somewhere in the logic ) the reference with the vb6 application i... | c # .net COM dll breaks reference with vb6 application |
C_sharp : I am using FxCopCmd tool for static code analysis . Since we already had a huge codebase , we baselined existing issues using baseline.exe tool that comes with FxCop.I am observing that if I add a new method to my C # class , then some of the suppression messages in GlobalSuppression.cs file stop working and ... | FxCop : Suppression message for async method |
C_sharp : I am writing a live-video imaging application and need to speed up this method . It 's currently taking about 10ms to execute and I 'd like to get it down to 2-3ms.I 've tried both Array.Copy and Buffer.BlockCopy and they both take ~30ms which is 3x longer than the manual copy.One thought was to somehow copy ... | How to optimize copying chunks of an array in C # ? |
C_sharp : I have the following objects structureIs there any way to make some kind of binding between these parent and child interfaces in DryIOC ? EDIT : I did some research and found that RegisterMany did the trick but I am a bit confused becauseIf I uncomment back individual registrations lines above , Resolve works... | How to resolve using parent hierarchy interfaces using DryIOC |
C_sharp : Note 1 : Here CPS stands for `` continuation passing style '' I would be very interested in understanding how to hook into C # async machinery.Basically as I understand C # async/await feature , the compiler is performing a CPS transform and then passes the transformed code to a contextual object that manages... | How to use C # async/await as a stand-alone CPS transform |
C_sharp : Is there a cost in passing an object to a function that implements a particular interface where the function only accepts that interface ? Like : and I pass : which all of them implements IEnumerable . But when you pass any of those to the Change method , are they cast to IEnumerable , thus there is a cast co... | C # interface question |
C_sharp : I 'm implementing an automatic `` evaluator '' for a course I 'm currently teaching . The overall idea is that every student delivers a DLL with some algorithms implemented . My evaluator loads all these DLLs using Reflection , finds the student implementations and evaluates them in a tournament . All these a... | Avoiding user code calling to Reflection in C # |
C_sharp : Today I was debugging some code of mine that builds a few ExpressionTrees , compiles them to callable Delegates and calls them afterwards if required . While doing this I encountered a FatalExecutionEngineError stepping through the code : At first I was a little bit shocked since I had no idea what could have... | C # Expressions - FatalExecutionEngineError |
C_sharp : IEnumerable is a query that is lazily evaluated . But apparently my understanding is a bit flawed . I 'd expect the following to work : What am I misunderstanding here ? How can I alter the results of what this query returns ? <code> // e.Result is JSON from a server JObject data = JObject.Parse ( e.Result ) ... | Changes to an IEnumerable are not being kept between queries |
C_sharp : first time posting , please be kind ! : - ) New to VB/C # , Trying to fix up a CLR function that calls a web service . I 've cobbled together the following : This will only return 4000 characters even though it is coded for sqlChars . The API call could potentially return upwards of 14MB during a full invento... | CLR function will not return more than 4000 chars |
C_sharp : I think there are people who may be able to answer this , this is a question out of curiosity : The generic CreateInstance method from System.Activator , introduced in .NET v2 has no type constraints on the generic argument but does require a default constructor on the activated type , otherwise a MissingMeth... | More trivia than really important : Why no new ( ) constraint on Activator.CreateInstance < T > ( ) ? |
C_sharp : I would like to build a facebook application similar to nametest or Meaww and almost succeeded to have my API calls to Facebook Graph API and return data from facebook.What makes me confused is the UI of aforementioned web applications . When you complete a test on Meaww or Nametests the result is represented... | Is there anyway to make one image out of 3 image URLs using asp.net mvc ? |
C_sharp : Assume that I have a class that exposes the following event : How should methods that are registered to this event be named ? Do you prefer to follow the convention that Visual Studio uses when it assigns names to the methods it generates ( aka . += , Tab , Tab ) ? For example : Or do you use your own style t... | Naming methods that are registered to events |
C_sharp : F # provides a feature , where a function can return another function . An example of function generating a function in F # is : The best way I could come up with to achieve the same in C # was this : Is there some other way ( /better way ) of doing this ? <code> let powerFunctionGenarator baseNumber = ( fun ... | Best way to generate a function that generates a function in C # |
C_sharp : I 'm loading in a solution in the MSBuildWorkspace : Projects without ProjectReferences show all MetadataReferences , including mscorlib . Projects with ProjectReferences have an empty collection of MetadataReferences . As compilation works , I guess the compiler platform for some reason is not populating thi... | Project MetadataReferences is not populated when ProjectReferences are present |
C_sharp : I have a User entity which has a HasCompletedSecurity property which indicates whether that particular User has answered the number of security questions required by the system . The number of security questions the system requires is configurable and retrieved from a config file . How should the User class a... | Domain Driven Design : access a configured value from an Entity without using a Service Locator |
C_sharp : My code calls a WCF service that is current not running . So we should expect the EndPointNotFoundException . The using statement tries to Close ( ) the faulted connection which causes a CommunicationObjectFaultedException which is excepted . This exception is caught in a try catch block surrounding the using... | Visual studio breaks on exception that IS handled with unhandled exception dialog |
C_sharp : I managed to consume a java based web service ( third party ) with WS-Security 1.1 protocol . The web service needs only to be signed over a x509 certificate , not encrypted.But I 'm getting this error : The signature confirmation elements can not occur after the primary signature.The captured server response... | WCF Client consuming WS-Security webservice |
C_sharp : Here is a part of my code : I expect testBranches will be https : //127.0.0.1:8443/svn/CXB1/Validation/branches/test , but it is https : //127.0.0.1:8443/svn/CXB1/Validation/test . I can not understand why Uri ( Uri , string ) constructor eats the last part of the path . <code> Uri branches = new Uri ( @ '' h... | Uri ( Uri , String ) constructor does not works properly ? |
C_sharp : On the current project we are working on we have n't upgraded to MVC 2.0 yet so I 'm working on implementing some simple validation with the tools available in 1.0.I 'm looking for feedback on the way I 'm doing this.I have a model that represents a user profile . Inside that model I have a method that will v... | Simple ASP.Net MVC 1.0 Validation |
C_sharp : I tried to use firewallAPI.dll to add a rule . It works fine for calc.exe ( or some other files ) as described bellow but fails for msdtc.exe with the following exception : System.IO.FileNotFoundException : 'The system can not find the file specified . ( Exception from HRESULT : 0x80070002 ) 'Example : Note :... | Add a firewall rule for Distributed Transaction Coordinator ( msdtc.exe ) |
C_sharp : I have the following code : What 's the difference between passing a pointer and a ref keyword as a parameter in the method ? <code> class Program { private unsafe static void SquarePtrParam ( int* input ) { *input *= *input ; } private static void SquareRefParam ( ref int input ) { input *= input ; } private... | What is the difference between referencing a value using a pointer and a ref keyword |
C_sharp : When generating GetHashCode ( ) implementation for anonymous class , Roslyn computes the initial hash value based on the property names . For example , the class generated foris going to have the following GetHashCode ( ) method : But if we change the property names , the initial value changes : What 's the r... | Why does initial hash value in GetHashCode ( ) implementation generated for anonymous class depend on property names ? |
C_sharp : I need to find out what the current Row index from within a foreach loop.An exception can occur at any point within the try/catch block , but if I use an incremental counter within the foreach loop , and the exception occurs outside of the loop , I 'll get an invalid row because I 've moved the pointer along ... | Clean implementation of storing current row index |
C_sharp : I use EntityFramework 4 + generated POCOs with Lazy loading disabled.Let 's say there are SQL tables named Table1 , Table2 , Table3 and Table4 and assume they contain some data.Let 's assume the simplified POCO representation of these tables looks like this : If the following code would be executed : EF would... | Query returning nothing when there is data in the database |
C_sharp : Update ! See my dissection of a portion of the C # spec below ; I think I must be missing something , because to me it looks like the behavior I 'm describing in this question actually violates the spec.Update 2 ! OK , upon further reflection , and based on some comments , I think I now understand what 's goi... | Equivalent implicit operators : why are they legal ? |
C_sharp : I came accross the following code today and I did n't like it . It 's fairly obvious what it 's doing but I 'll add a little explanation here anyway : Basically it reads all the settings for an app from the DB and the iterates through all of them looking for the DB Version and the APP Version then sets some v... | A C # Refactoring Question |
C_sharp : Suppose I have following program : I can not understand compiled il code ( it uses too extra code ) . Here is simplified version : Why does compiler create not static equal methods b/b1 ? Equal means that they have the same code <code> static void SomeMethod ( Func < int , int > otherMethod ) { otherMethod ( ... | Weird behaviour of c # compiler due caching delegate |
C_sharp : Any suggestion how to make the below query more `` readable '' ? Its difficult to read with the long code of condition and value . <code> var result = result .OrderBy ( a = > ( conditionA ) ? valueA : ( conditionB ? valueB : ( conditionC ? ( conditionD ? valueC : valueD ) : valueE ) ) ) ; | Ternary operator difficult to read |
C_sharp : I hear that Nullable < T > is a C # generic class and it does not work with COM - like any other generic class.Well , in my C # class library I have : Surprisingly that compiles and I am able to attach references to my COMClass library in VBE.I know that : VBA does not list .GetNullable ( ) in the list of mem... | How does a COM server marshal nullable in C # class library with different ComInterfaceType Enumerations ? |
C_sharp : Does using the braced initializer on a collection type set it 's capacity or do you still need to specify it ? That is , does : result in the same as this : <code> var list = new List < string > ( ) { `` One '' , `` Two '' } ; var list = new List < string > ( 2 ) { `` One '' , `` Two '' } ; | Does using the braced initializer on collection types set the initial capacity ? |
C_sharp : Had to pick up a bit of work from another developer so just trying to wrap my head round it all ! But I 'm having issues building an Azure Functions project and continuously getting a error coming form Microsoft.NET.Sdk.Functions.Build.targets , specifically unable to resolve a reference to Microsoft.Azure.We... | Failed to resolve for reference Microsoft.Azure.WebJobs.Extensions - Metadata generation failed |
C_sharp : Apps downloaded from the Windows Store are installed in this location : If you look inside this folder you can access each application 's .exe and use reflector to decompile them.Currently , my Windows RT application sends a password over SSL to a WCF service to ensure that only people using my app can access... | What can I do to stop other people running my Windows RT code ? |
C_sharp : I 'm attempting to find a minimized window and Show it.The program can be downloaded from Samsung and it is titled `` SideSync '' . To fully replicate my question you would need to install this and also have a Samsung phone to plug in to your computer . Here is a screen shot of it fully configured and running... | C # minimized windows not being returned by call to System.Diagnostics.Process.GetProcesses ( ) |
C_sharp : I have a form which I 'm bringing up using ShowDialog which contains a couple of text boxes , labels and a button . The problem I 'm having is that the text boxes are being drawn before the form itself and the other controls are drawn.I am overriding the OnPaint method I 'm not sure if this could be causing t... | Controls not being drawn at the same time |
C_sharp : I have a form in HTML which contains multiple same name fields . For example : Now on the server side ( C # ) , I have an action method and a model class Product : Now my question is : I am submitting the form using jquery $ .ajax method . On the server side the action method accepts a Product class array . N... | How to serialize the form fields and send it to server , jquery ? |
C_sharp : I 've an array of objects DataTestplans from which I try to retrieve records for a particular DataID and ProductID using the LINQ query shown , my current query has Distinct ( ) which distiguishes on all 5 mentioned properties , how do I retrieve distinct records based on properties DataID , TestPlanName , TC... | how do I write LINQ query to retrieve distinct records based on only specific properties ? |
C_sharp : I am trying to achieve something like this : So I can do something like this : Is this possible ? <code> interface IAbstract { string A { get ; } object B { get ; } } interface IAbstract < T > : IAbstract { T B { get ; } } class RealThing < T > : IAbstract < T > { public string A { get ; private set ; } publi... | Generics IAbstract < T > inherits from IAbstract |
C_sharp : Yes , I am using a profiler ( ANTS ) . But at the micro-level it can not tell you how to fix your problem . And I 'm at a microoptimization stage right now . For example , I was profiling this : ANTS showed that the y-loop-line was taking a lot of time . I thought it was because it has to constantly call the ... | How do I learn enough about CLR to make educated guesses about performance problems ? |
C_sharp : Consider this example code : Here B.TheT is null . However , changing the Main method like this : B.TheT is `` Test '' , as expected . I can understand that this forces the static constructor to run , but why does this not happen for the first case ? I tried reading the spec , and this caught my attention ( §... | Static initialization of inherited static member |
C_sharp : Using C # for ASP.NET and MOSS development , we often have to embed JavaScript into our C # code . To accomplish this , there seems to be two prevalent schools of thought : The other school of thought is something like this : Is there a better way than either of these two methods ? I like the second personall... | How do you embed other programming languages into your code ? |
C_sharp : In C # you can refer to values in a class using the 'this ' keyword.While I presume the answer will likley be user preference , is it best practice to use the this keyword within a class for local values ? <code> class MyClass { private string foo ; public string MyMethod ( ) { return this.foo ; } } | Should you always refer to local class variables with `` this '' |
C_sharp : I have a piece of software written with fluent syntax . The method chain has a definitive `` ending '' , before which nothing useful is actually done in the code ( think NBuilder , or Linq-to-SQL 's query generation not actually hitting the database until we iterate over our objects with , say , ToList ( ) ) ... | How to enforce the use of a method 's return value in C # ? |
C_sharp : I 'm using Newtonsoft JSON library and I 'm trying to deserialize a JSON . The problem is that when I use [ JsonConverter ( typeof ( StringEnumConverter ) ) ] I get this error : Can not apply attribute class 'JsonConverter ' because it is abstract.Here are my classes : I get the squiggly line under the JsonCo... | Can not apply attribute class 'JsonConverter ' because it is abstract |
C_sharp : I have a code which updates an array based on values in another , small array.Where c is a struct that is a pair of bytes representing cards from a deck.one is an array size of 52 ( with entries for each of 52 cards from a deck ) I wrote a benchmark to profile this code : Setting testRepetitions = 25 million ... | Accessing 5-byte struct is much slower than 8-byte |
C_sharp : return confControl ; throws an exception : Can not implicitly convert type ConfigControlBase < ProviderX > to ConfigControlBase < ProviderBase > <code> public class ConfigControlBase < T > : UserControl where T : ProviderBase { public T Provider { get ; set ; } public void Init ( T provider ) { this.Provider ... | Casting a generic element type downwards |
C_sharp : What 's the simple way to add the dollar sign ( ' $ ' ) or currency to a decimal data type on the following query : Thanks for the help ! <code> SELECT TOP 100000 SUM ( [ dbo ] . [ Entry ] . [ Amount ] ) AS 'Total Charges ' | How to convert , cast , or add ' $ ' to a decimal SQL SUM ( ) |
C_sharp : In Perl I can sayWhat is the equivalent of this in C # ASP.NET ? Specifically what I 'm looking for is something so that other members of my team can know when they 're still using a deprecated routine . It should show up at run time when the code path is actually hit , not at compile time ( otherwise they 'd... | What 's the C # equivalent of perl warn ? |
C_sharp : This question is not so much about finding a solution as about getting an explanation for the bizarrest behavior I have ever seen from SQL Server.I had a stored procedure with the following signature : Given a certain set of parameters , this proc was taking a very long time to run from C # ( using SqlCommand... | Stored procedure performance - this is WILD ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.