text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I have a parent object that has a reference to a child object and additionally the parent has an event handler that listens to an event of the child object.If all references to the parent object will be released , will the memory used through the parent and the child be freed through GC ? ( Assuming that no m... | Will GC release used memory |
C_sharp : I 'm working on a game here , and found this rather intriguing bug . Suppose you have this enum : a base classand two instances of it : This is what happened to me : The first instance 's type would remain as pre-initialized in the base class , even though I specified in its constructor that I want the type t... | Strange behavior with C # enums |
C_sharp : Just wondered why the discrepancy really . : -/ <code> //okAction < int > CallbackWithParam1 = delegate { } ; //error CS1593 : Delegate 'System.Action < int > ' does not take 0 argumentsAction < int > CallbackWithParam2 = ( ) = > { } ; | Why can anonymous delegates omit arguments , but lambdas ca n't ? |
C_sharp : I 'm trying my hand at behavior driven development and I 'm finding myself second guessing my design as I 'm writing it . This is my first greenfield project and it may just be my lack of experience . Anyway , here 's a simple spec for the class ( s ) I 'm writing . It 's written in NUnit in a BDD style inste... | Is this a poor design ? |
C_sharp : System.Array serves as the base class for all arrays in the Common Language Runtime ( CLR ) . According to this article : For each concrete array type , [ the ] runtime adds three special methods : Get/Set/Address.and indeed if I disassemble this C # code , into CIL I get , where the calls to the aforemention... | Where can I find information on the Get , Set and Address methods for multidimensional System.Array instances in .NET ? |
C_sharp : Given event store with fields : AggregateId : integerPayload : blobVersion : integerWhich contains events based on : ... and then has further events added with an updated structure : When this historical data is retrieved ( for analysis , etc ) , how do you reconstruct binary payload into meaningful data ? No... | How to retrieve historical events after changes to Domain Event structure |
C_sharp : How can I get Visual Studio to provide controller and action syntax highlighting like it offers for its own object for controller and action strings in the following ? When you use : Visual Studio provides additional highlighting on the controller and action , it even tries to detect which ones are available ... | How to get syntax highlighting of controllers and actions on HtmlHelper extension method ? |
C_sharp : I 'm trying to create a Generic Action Delegate andand here is my callerand here is the business objectand here is the error what i get during compilationMy GetSetterAction is returning ActionPerdicate where as here T is busPerson and i am trying to store it in ActionPredicate keeping in mind about Contravari... | Contravariance in Expressions |
C_sharp : I thought that ^ did that.I expected : What I 'm gettingthe actual code isreplacing exp for 0 , 1 , and 2What does the ^ operator do ? <code> 10^0=110^1=1010^2=100 10^0=1010^1=1110^2=8 int value = 10 ^ exp ; | What does ^ operator do ? |
C_sharp : I came across this situation where the following plinq statement inside static constructor gets deadlocked : It happens only when a constructor is static.Can someone explain this to me please.Is it TPL bug ? Compiler ? Me ? <code> static void Main ( string [ ] args ) { new Blah ( ) ; } class Blah { static Bla... | Plinq statement gets deadlocked inside static constructor |
C_sharp : Total OO noob question here . I have these two methods in a class And when I call StoreSessionSpecific with dbSession being of type LateSession ( LateSession inherits Session ) I expected the top one to be called . Since dbSession is of type LateSession . @ Paolo Tedesco This is how the classes are defined . ... | Why is n't the most specific method called based on type of parameter |
C_sharp : My ultimate goal here is to turn the following string into JSON , but I would settle for something that gets me one step closer by combining the fieldname with each of the values.Sample Data : Using Regex.Replace ( ) , I need it to at least look like this : Ultimately , this result would be awesome if it can ... | Need some help on a Regex match / replace pattern |
C_sharp : Conversion failed when converting the varchar value 'DADE ' to data type int.SQL command which i use is this : My code is : <code> SELECT * FROM p_details WHERE LOWER ( name ) LIKE ' % has % ln % ' AND CODE = 13 AND T_CODE= ' H ' SqlDataReader drr = com4.ExecuteReader ( ) ; DataTable dt = new DataTable ( ) ; ... | Error when data is bind into data table or gridview |
C_sharp : I 've been having this problem for awhile in Visual Studio 2013 . It does n't seem to understand how to apply the indentation rules properly to lambda expressions when they 've been lined up incorrectly . Here is a simplified example : In the second and third row , the indent is only 3 spaces instead of 4 ( t... | Incorrect Lambda Expression Indentation |
C_sharp : We have an entity in our system called an `` identity program . '' That is also our sharding boundary , every identity program is stored in its own shard , so the identifier of the shard is the identifier of the identity program.We are in the process of implementing the ability to physically delete an identit... | Can not delete shard mapping using Azure SQL Elastic Scale |
C_sharp : I have an method that throws exception : I 'm using this method in more than 100 places in my code , the problem is when i use this method in another method that must return a value Re-sharper dose not understands that there is no need for returning a value , for example : is there any way to tell Re-sharper ... | How could i let Resharper or Intellisense know that a method allwayse throws exception ? |
C_sharp : First some information about my development environment : .Net Framework 4.5Moq 4.10Autofac 4.2NUnit 3.11I try to mock a function that takes some string arguments and I would like to use It.IsAny < string > ( ) to setup . Normally I would to that like this : But now I would like to call a fucntion that makes ... | Passing Moqs It.IsAny < string > as method argument |
C_sharp : I 'm tring to create a class which does all sorts of low-level database-related actions but presents a really simple interface to the UI layer.This class represents a bunch of data all within a particular aggregate root , retrieved by a single ID int.The constructor takes four parameters : The UI layer access... | Architecture problem : use of dependency injection resulting in rubbish API |
C_sharp : The following F # code declares base and descendant classes . The base class has a virtual method 'Test ' with a default implementaion . The descendant class overrides the base class method and also adds a new overloaded 'Test ' method . This code compiles fine and presents no issues when accessing either of ... | Can not resolve an F # method that has been both overridden and overloaded from C # |
C_sharp : I 'm trying to create a MediaComposition . I have succeeded in combining multiple png images into a single video ; however , the files that 's created has a black background . At first I thought this might be because the files were png files , but the same bevaviour occurs for jpgs . The following is how I 'm... | Add a background colour to a MediaComposition |
C_sharp : I have a function that makes a list of animals , some of which are dogs , and some of which are just animals . That function returns that list to a different function that wants to extract out just the dogs , which is possible because the Animal class has a bool isDog . My question is , is it possible to extr... | When a Child class is added to a List < parent > , is the child-specific data lost ? |
C_sharp : I have following entity : What I need is to create optional-to-optional relationship within the same entity using PreviousRevision as a navigation property and PreviousRevisionId as a foreign key Id for it.I know that it can be done by annotating PreviousRevisionId property with [ ForeignKey ( `` PreviousRevi... | EF6.1 optional-to-optional with fluent api mapping |
C_sharp : First - a disclaimer : If you 're reading this because you want to use both a binding for IsChecked and a RelayCommand to change things , you probably are doing it wrong . You should be working off of the IsChecked binding 's Set ( ) call.The question : I have a ToggleButton in which there 's both a binding f... | What executes first : ToggleButton.IsChecked binding update , or Command binding ? |
C_sharp : I was trying to find out if setting the capacity of a list in the constructor could flatten the already negligible performance differences between using List < T > ( IEnumerable < T > ) vs List < T > ( ) + AddRange ( IEnumerable < T > ) .I found out setting the capacity before AddRange ( ) actually leads to r... | Performance difference with various List initialization and population techniques |
C_sharp : I have a method that is looping through a list of values , what I would like to do is when I open the page to be able to see the values changing without refreshing the current view . I 've tried something like the code bellow.The actual thing is I want it to read this values even if I close the form . I presu... | How to display different values without refreshing the page MVC C # |
C_sharp : for access control purposes in a intensive DB use system I had to implement an objectset wrapper , where the AC will be checked.The main objective is make this change preserving the existing code for database access , that is implemented with linq to entities all over the classes ( there is no centralized lay... | ObjectSet wrapper not working with linqToEntities subquery |
C_sharp : I 'm trying to fill a data grid view in my windows form application but nothing is being returned from the database when I execute the select query . I 've looked at other questions about this topic on this site but can not find anything that addresses my problem . The name of the data view table is qbcMemDat... | SQLite Data Adapter not displaying data |
C_sharp : I have a question regarding the symbol that separates days from hours in TimeSpan.ToString output.The standard TimeSpan format strings produce different separator symbols : '' c '' produces a period ( `` . '' ) character '' g '' and `` G '' produce a colon ( `` : '' ) characterExample : Does anybody know what... | Strange TimeSpan.ToString output |
C_sharp : I am looking for a way to ensure that only serializable objects are stored into a Dictionary in C # .To be more specific I 'm looking to do something similar to this : The problem with this is that I can not store primitive types like integers , booleans , or strings.Is there a way to ensure that my Dictionar... | Dictionary containing with only Serializable objects |
C_sharp : I am using Dapper to call a stored procedure which have a mandatory parameter @ idProjectthis is my code fragment : Should work but raise an exception : An exception of type 'System.Data.SqlClient.SqlException ' occurred in System.Data.dll but was not handled in user code Additional information : Procedure or... | Mandatory parameters , Dapper and System.Data.SqlClient.SqlException |
C_sharp : I 'm working on a relatively straight forward C # project that connects an Access Database via OleDb with various functions such as adding , deleting and editing records . Now , everything has worked fine up until trying to implement a database search . The following line ( in the searchbox code ) throws up t... | NullReferenceException error when searching database table for entries |
C_sharp : I 'm trying to understand this RegEx statement in details . It 's supposed to validate filename from ASP.Net FileUpload control to allow only jpeg and gif files . It was designed by somebody else and I do not completely understand it . It works fine in Internet Explorer 7.0 but not in Firefox 3.6 . <code> < a... | Understand this RegEx statement |
C_sharp : I want to split a border attribute from CSS into its constituent parts i.e : IntoI have split off the border : and semi-colon before this , so I simply need to parse the value section of the attributeNow in CSS you can have any combination of the 3 above attributes present soAll are legal so I need to account... | Regex for splitting CSS border attribute into its parts |
C_sharp : I have a list of bugs MyBugList created using the following classI wanted to group these bugs based on State and Severity . I used the following code to achieve it.This linq query gives me output like the followingHowever I would like to get an output like belowIs it possible to get this via a LINQ query on M... | LINQ query on an object list to get distribution based on multiple fields |
C_sharp : I have some doubts regarding the using statement : I have a class called MyJob which is Disposable . Then i also have a property on MyJob JobResults that is also Disposable.MY code : MY First question is : In this case after the using block are both MyJob and MyJob.Results disposed or only MyJob and NOT MyJob... | using statement usage in C # |
C_sharp : I was cleaning up some code and removed an if statement that was no longer necessary . However , I realized I forgot to remove the brackets . This of course is valid and just created a new local scope . Now this got me thinking . In all my years of C # development , I have never come across a reason to use th... | Explicit Local Scopes - Any True Benefit ? |
C_sharp : I 'm trying to wrap my head around what the C # compiler does when I 'm chaining linq methods , particularly when chaining the same method multiple times.Simple example : Let 's say I 'm trying to filter a sequence of ints based on two conditions.The most obvious thing to do is something like this : But we co... | Understanding how the C # compiler deals with chaining linq methods |
C_sharp : Env : C # , VStudio 2013 , 4.5 Framework , WinformsGoal : Getting the number of files ( Count ) in a folder and subfolder that match extensions stored in an array of string . The array of extension can be with the `` . '' of not . { `` .dat '' , '' txt '' , '' .msg '' } What i 've done so far : When I 'm havi... | Count of files in C # with LINQ |
C_sharp : Which way can I decide the computer has a wifi adapter ? When I test my code it works , but I am uncertain , will it always work ? <code> private bool hasWifi ( ) { try { WlanClient wlanclient = new WlanClient ( ) ; } catch ( System.ComponentModel.Win32Exception except ) { return false ; } return true ; } | How to determine if the computer has a wifi adapter ? |
C_sharp : I 'm trying to set up CSP in an asp.net core webapp , and the CSP part works fine , I can see the violations in the browser console as they are sent to the report-uri endpoint.However , I can not seem to create the correct method in a controller to receive these messages ! I create a method in the controller ... | csp-report endpoint in asp.net core |
C_sharp : What is the proper XML-comment syntax to refer to the SingleOrDefault extension method on the IEnumerable interface ? My latest attempt is : The warning is : XML comment on 'yourMethod ' has cref attribute 'IEnumerable.SingleOrDefault ( ) ' that could not be resolved <code> < see cref= '' IEnumerable { T } .S... | How to refer to an extension method of a generic class in XML comments |
C_sharp : So I have the following block of code inside a method : ( all variables are local ) As you can see , the two try statements are different , but the two sets of catch statements are exactly the same . I 've been trying to think of a way that it might be possible to not repeat myself here , but I have n't reall... | DRY With Different Try Statements and Identical Catch Statements |
C_sharp : Given an async method : And calling it through an intermediate method , should the intermediate method await the async method IntermediateA or merely return the Task IntermediateB ? As best I can tell with the debugger , both appear to work exactly the same , but it seems to me that IntermediateB should perfo... | Call chain for async/await ... await the awaitable or return the awaitable ? |
C_sharp : I have seen code with the following logic in a few places : What is the point of setting foo to null in the dictionary before removing it ? I thought the garbage collection cares about the number of things pointing to whatever *foo originally was . If that 's the case , would n't setting myDictonary [ `` foo ... | Can someone explain what the point of nulling an object before it goes out of scope is ? |
C_sharp : There is library A calling library B using a C # extension method.I got a weird error from the C # compiler : The type 'System.Windows.Forms.Control ' is defined in an assembly that is not referenced . You must add a reference to assembly 'System.Windows.Forms , Version=4.0.0.0None of the libraries A or B are... | Extension method call does not compile , but static method call to same code does compile |
C_sharp : Consider the following code : To my surprise , this outputs 47 ; in other words , the explicit operator long is called even though the cast is to decimal.Is there something in the C # spec that explicitly says that this should happen ( if so , where exactly ) or is this the result of some other rule ( s ) I ’... | Why does an explicit cast to ‘ decimal ’ call an explicit operator to ‘ long ’ ? |
C_sharp : I have this XAML : Is there some way to shift that unicode character & # x24D8 ; into a shared resource ( like a constant or a StaticResource ) ? What I have triedMethod 1This works fine , but it requires a valid binding to work : And in code behind : Method 2This method seems like it might work , but no luck... | WPF : How to shift Unicode character into a shared resource ? |
C_sharp : The grid in WPF currently has a grid system like this : Is there a way to make it behave like this : Ideally I would like the RowSpan to extend an item upwards instead of downwards . Example : My datasource stores a cube on the map as 0,0 with the intent of it being displayed on the bottom left corner . Howev... | Change Grid Coordinate System |
C_sharp : I have been trying to draw equilateral triangles on the sides of a larger triangle . The first triangle is drawn by a separate method setting points A , B and C. So far I have just started with two sides , I am able to find the first two points of the smaller triangles , but I am unable to determine the corre... | C # Drawing equilateral triangles on the sides of another equilateral triangle |
C_sharp : Possible Duplicate : Define a generic that implements the + operator I am recently working on a C # class library implementing an algorithm . The point is that I would like the users of the library to be able to choose the machine precision ( single or double ) the algorithm should operate with , and I 'm try... | How to impose , in a C # generic type parameter , that some operators are supported ? |
C_sharp : I can type In fact , I expect I could keep going adding dimensions to Int.MaxValue though I have no idea how much memory that would require.How could I implement this variable indexing feature in my own class ? I want to encapsulate a multi dimensional array of unknown dimensions and make it available as a pr... | How to implement Array indexer in C # |
C_sharp : I am trying the code to find out whether the user has already signed in or not ? Even if the user has already logged in , it returns Unknown . What is the problem with this ? <code> LiveAuthClient LCAuth = new LiveAuthClient ( ) ; LiveLoginResult LCLoginResult = await LCAuth.InitializeAsync ( ) ; | LiveLoginResult.Status is Unknown ? |
C_sharp : How would I convert this to HttpClient ? What I 'm looking to do is submit a Tweet to the Twitter api and get the response as Json . The HttpWebRequest is working fine but I just want to port it to HttpClient . I made an attempt at it in the second code example , but it 's not actually sending or receiving th... | Refactor HttpWebRequest to HttpClient ? |
C_sharp : I 'm receiving several bit fields from hardware.My code was originally : Then I remembered the flags enum and am considering changing it to : and so on.Which is best practice and what if any are the pros and cons of each approach ? EDIT : I 'm interested to know if there are any practical differences between ... | What are the pros and cons of using a flags enum ? |
C_sharp : Take a look at the code : I want to remove all whitespace from the original string and then get the individual characters.The result surprized me.The variable exprCharsNoWhitespace contains , as expected , no whitespace , but unexpectedly , only almost all of the other characters . The last occurence of ' & '... | Why is one character missing in the query result ? |
C_sharp : I used to be a C++ programer on Windows.I know that the compiler will optimizes the ternary operator in C++.C++ code : Because of the pipeline stuff , the generated native code is shown as below ( of course Release model ) : C # code : I looked up the native code JIT generated , but there is no optimization a... | C # vs C++ ternary operator |
C_sharp : I 've struggled a lot with how to show a modal panel on click on a button inside a grid view.To context : I have a data row with a string field that can contain a simple text or a base 64 encoded image , so I 'm using a custom template to define when to show the raw content or a button `` View Image '' . This... | Modal Panel Doesn ’ t Appear When Called by Button Inside a Grid View ’ s Cell |
C_sharp : I have the following structureOn the code behind I get the repeater ItemDataBound event , get the control using var button1 = e.Item.FindControl ( `` Button1 '' ) as LinkButton ; then I assign a CommandArgument with the ID of the current element.This is being executed immediately after the CreateChildControls... | How to change a View with a button on a Repeater ? |
C_sharp : ContextWe have a C # program , that deals with time.We have clients in France , so we convert times to and from France 's timezone.In our C # code : we use Central European Standard Time as a time zone for France.It describes a timezone , which follows DST changes : on the last sunday of march ( 3 AM ) , cloc... | What timezone should I use for France to support old and new daylight saving adjustments ? |
C_sharp : In C # when an Task or Task < T > method is returned from within a using statement is there any risk of the cleanup not properly occurring , or is this a poor practice ? What concerns are there as it pertains to the closure of the variable in the using block ? Consider the following : In the example above the... | C # Task returning method in using block |
C_sharp : I ’ m writing console application which does some work by scheduler and write output to console . Everything is good but when I click on the console it stops working and waits for my right click . After that it continues working.I thought that it simply doesn ’ t write text to console and does what it needs t... | Console application ( C # ) is stuck while interaction |
C_sharp : Is there a way to put the GC on hold completely for a section of code ? The only thing I 've found in other similar questions is GC.TryStartNoGCRegion but it is limited to the amount of memory you specify which itself is limited to the size of an ephemeral segment.Is there a way to bypass that completely and ... | Put GC on hold during a section of code |
C_sharp : We have entity framework implemented in our Web API 2.0 code . To call database entities , we are using store procedure calls . Our entire application is hosted in Microsoft Azure cloud . Here are the two exception which we are facing.Message : An error occurred while executing the command definition . See th... | SQL Connection Errors in Microsoft Azure |
C_sharp : How can I bind a control inside a usercontrol resource to a property ? Alternatively , can I find the control from the code behind and get & set the value from there ? Here is my markup . I 've stripped it down to just the relevant part : Salesmen.xaml : And here 's my property . Despite the two-way binding i... | How can I bind or otherwise get & set a value of a control in a resource ? |
C_sharp : I have defined the following classes and methods : This compiles fine . Woo hoo ! Half-way there . Then , I try to use it later with code like this : This , however , dies with the following error message The type ToolStripStatusLabel can not be used as type parameter C in the generic type or method Something... | Why Does C # Not Bind Correctly to Generic Overridden Methods ? |
C_sharp : is evaluated to 108 . Why ? IMO the ( int ) -cast should be evaluated after the multiplication . <code> ( int ) ( ( float ) 10.9 * 10 ) | Understanding the given calculation ( cast + multiplication ) |
C_sharp : I 'm writing a program that writes C # that eventually gets compiled into an application . I would like each of the generated types to provide a `` deep clone '' function which copies the entire tree of data . That is , I want someone to be able to do : instead ofHowever , C # does n't allow you to do this in... | Is it possible to implement the `` virtual constructor '' pattern in C # without casts ? |
C_sharp : I 'm trying to update a project which makes heavy use of comparison against SyntaxToken.Kind . This property appears to have disappeared in newer versions of Roslyn and I wondered if there an alternative method or an extension method I could write to get the same functionality ? The code has many references s... | How to get the SyntaxToken.Kind in current version of Roslyn ? |
C_sharp : I am still new to overloading operators . I thought i was doing a great job until i hit this problem . NullReferenceException is thrown on the ! = operator . I assume its using it in the CompareTo method but i 'm not totally sure . If anyone can point me in the right direction i would be very grateful.When i ... | How to properly override equality ? |
C_sharp : Consider the following class : This is what the compiler generates ( in a slightly less readable way ) : This way the delegate passed with the first call is initialized once and reused on multiple Test calls.However , the expression tree passed with the second call is not reused - a new lambda expression is i... | Why do n't non-capturing expression trees that are initialized using lambda expressions get cached ? |
C_sharp : I am working on a library of COM Add-in and Excel Automation Add-in , whose core codes are written in C # . I 'd like to set an optional argument for the function and I know that this is legal for both C # and VBA , and even Excel WorksheetFunction . But I find that finally the optional argument works exclusi... | Optional Argument of COM Add-in vs Automation Add-in Written in C # |
C_sharp : Possible Duplicates : confused with the scope in c # C # Variable Scoping I am curious about the design considerations behind the scope of variables which are declared in the initialization part of for-loops ( etc ) . Such variables neither seem to be in-scope or out-of scope or am I missing something ? Why i... | C # : Definition of the scope of variables declared in the initialization part of for-loops ? |
C_sharp : For a project I 'm busy with the Google Adwords api ( client library = C # ) . I show the visitor an estimate of traffic based on keywords and locality/city currently . It 's using following methodhttps : //developers.google.com/adwords/api/docs/guides/traffic-estimator-serviceI want to add an extra requireme... | How add a radius / proximity around a city for estimating traffic ( Google Adwords ) ? |
C_sharp : I 'm trying to create a simple program with MonoGame in Xamarin Studio 4.0.10 ( build 5 ) .But when I try to load some textures using Content.Load method , I receive an exception System.MissingMethodException with a message The actual lines of code I am using are : I did some googling and found out that this ... | How to fix MissingMethodException during Content.Load < Texture2D > in Xamarin Studio on MacOS X ? |
C_sharp : I have a class project a.dll which is compiled in C # . It contains the following code.from a C # project I can call these functions like thisBut how can I call this from a VB.Net Project ? I am not in a position to use Visual Studio right now . So its very helpful if someone will provide an answer.EDIT 1I am... | How to call a function defined in C # with same params , return type and same name but in different case from a VB.NET project |
C_sharp : After Windows has updated , some calculated values have changed in the last digit , e.g . from -0.0776529085243926 to -0.0776529085243925 . The change is always down by one and both even and odd numbers are affected . This seems to be related to KB4486153 , as reverting this update changes the values back to ... | Rounding of last digit changes after Windows .NET update |
C_sharp : This is for Project Euler , problem 8.I am trying to foreach through the array of numbers , each time skipping the last number and pulling the next 13 adjacent numbers in the array.My code : The problem I 'm running into is , every time it enumerates through the array , it subtracts the amount that x is , fro... | array.Take ( 13 ) .Skip ( x ) is subtracting the take |
C_sharp : We have a WEB API project that recently was moved to a new server . I 'm running my project after making some additions to its ' payload , but it suddenly throws the following error : Unable to cast object of type 'System.Net.Http.Formatting.JsonContractResolver ' to type 'Newtonsoft.Json.Serialization.Defaul... | `` Unable to cast object of type 'System.Net.Http.Formatting.JsonContractResolver ' to type 'Newtonsoft.Json.Serialization.DefaultContractResolver ' . '' |
C_sharp : I have an object o that is known to be a boxed int or uint : I do n't know what 's in the box , all I care about is that there 's 4 bytes in there that I want to coerce to an int or uint . This works fine in an unchecked context when I have values ( instead of boxes ) : Note : By default everything in C # is ... | Unboxing uint/int without knowing what 's inside the box |
C_sharp : I an having Two Lists . I want to get the matched and unmatched values based on ID and add the results to another List . I can get both of these using Intersect/Except . But I can get only ID in the resultant variables ( matches and unmatches ) . I need all the properties in the Template . <code> List < Templ... | How to copy a List < > to another List < > with Comparsion in c # |
C_sharp : I wanted to mock an entityframwork DbSet using Foq . It goes something like : I tried coercing and casting x to an IQueryable at some places but that does n't work.As you can see here in the docs for DbSet it does implement the IQueryable interface via DbQuery , but does so by `` explicitly '' implementing th... | Mocking a class with an explicitly implemented interface using Foq |
C_sharp : I have these extension methods and enum type : The first if below compiles ; the second does not : They only vary by the extra set of parentheses . Why do I have to do this ? At first I suspected it was doing a double implicit cast from bool ? to bool and then back to bool ? , but when I remove the first exte... | Why do I have to place ( ) around null-conditional expression to use the correct method overload ? |
C_sharp : I 've normally been creating Prism Events used by the EventAggregator like : public class SomeEvent : CompositePresentationEvent < SomeEventArgs > { } But while looking at a co-workers code I noticed they did : I guess my first question is why does this even compile ? It seems to me that it 's implementing a ... | Define class with itself as generic implementation . Why/how does this work ? |
C_sharp : I am trying to clear all items from a ToolStripDropDownButton.Since they are disposable , I call the dispose method on each of them.But I see that after calling the dispose ( ) method , the IsDisposed property still returns false.Why is that and how can I check if Dispose ( ) is called on any object ? It is n... | Why does IsDisposed return false after calling Dispose ( ) ? |
C_sharp : I am college student ( computer science ) and have just started a C # programming class.For our assignments I have been using a class called `` Display '' where I put any console output that could be used several times throughout a project . For example , a request to continue or exit program . Instead of typ... | correct use of classes ? |
C_sharp : I 'm downloading an Excel file ( dynamically created in a Winforms app and saved to a database ) in a Web API project using this method : This works just fine ( except that there is no downloading action visible , such as the file 's icon dropping to the taskbar , as is normally the case when downloading file... | How can I download a file to a remote machine the same or similarly to how I 'm doing it to my own machine ? |
C_sharp : how can i optimized this code ? i dont like to have case statement , is there a way i can improve this code ? <code> protected void ddlFilterResultBy_SelectedIndexChanged ( object sender , EventArgs e ) { string selVal = ddlFilterResultBy.SelectedValue.ToString ( ) .ToLower ( ) ; switch ( selVal ) { case `` d... | how can i make this code more optimized |
C_sharp : What would be the best way to override the GetHashCode function for the case , whenmy objects are considered equal if there is at least ONE field match in them.In the case of generic Equals method the example might look like this : Still , I 'm confused about making a good GetHashCode implementation for this ... | C # GetHashCode question |
C_sharp : With Moq , it is possible to verify that a method is never called with certain arguments ( that is , arguments satisfying certain predicates ) using Times.Never.But how to verify that , no mater how many times a method is called , it is always called with certain arguments ? The default appears to be Times.At... | Why is n't there a Times.Always in Moq ? |
C_sharp : I thought it would be a good idea to use CancellationToken in my controller like so : The issue is that now Azure Application Insights shows a bunch of exceptions of type System.Threading.Tasks.TaskCancelledException : A Task was canceled . as well as the occasional Npgsql.PostgresException : 57014 : cancelin... | Stop Exception generated by CancellationToken from getting Reported by ApplicationInsights |
C_sharp : I 've just started with AutoMapper in C # . I 've succesfully created a mapping like this : I 've also found a way to add some logic to specific properties , like formatting a date ( in InputTypeA ) to a string in a specific format ( in OutputTypeA ) .Now I need to do the same for a number of float properties... | Special treatment for float properties in some but not all AutoMapper mappings |
C_sharp : Earlier today , as I was coding a method and it struck me that I was n't sure exactly why the idiom I was implementing compiles . If everything else is abstracted away , it would look something like this : You have an explicitly infinite loop , and some set of conditions inside the loop that cause the loop to... | Are explicitly Infinite Loops handled in .NET as a special case ? |
C_sharp : I know that multiple objects of same type can be used inside a using clause.Cant i use different types of objects inside the using clause ? Well i tried but although they were different names and different objects , they acted the same = had the same set of methodsIs there any other way to use the using class... | Can i have different type of objects in a C # *using* block ? |
C_sharp : What 's the easiest/straight-forward way of setting a default value for a C # public property ? // how do I set a default for this ? Please do n't suggest that I use a private property & implement the get/set public properties . Trying to keep this concise , and do n't want to get into an argument about why t... | C # Automatic Properties -- setting defaults |
C_sharp : When I am invoking a number of methods to a Dispatcher , say the Dispatcher of the UI Thread , like herewill those methods be executed in the same order as I have invoked them ? <code> uiDispatcher.BeginInvoke ( new Action ( insert_ ) , DispatcherPriority.Normal ) ; uiDispatcher.BeginInvoke ( new Action ( add... | Execution order of asynchronously invoked methods |
C_sharp : The definition System.Linq.ILookUp readsSince IEnumerable is covariant in IGrouping < TKey , TElement > , IGrouping < TKey , TElement > is covariant in TElement and the interface only exposes TElement as a return type , I would assume that ILookup is also covariant in TElement . Indeed , the definitioncompile... | Should n't ILookup < TKey , TElement > be ( declared ) covariant in TElement ? |
C_sharp : I have a problem where I want a group type to be strongly typed but if I do it does n't group correctly . See the code below ... The output : I would expect the result to be the same regardless of using an explicit type nor not i.e . should only be one group with 3 items not 3 groups with 1 item . What is goi... | Why does using anonymous type work and using an explicit type not in a GroupBy ? |
C_sharp : I have used the three fields in the program and got the difference in usage but I am little confused where does these fields are getting stored ? either in data segment ( stack or heap ? ) or code segment ? in ILDASM the the fields are described as the followingfor static : .field private static int32 afor co... | Where does the memory is allocated for static , constant and readonly fields ? |
C_sharp : Using WindowsForms technology , I 'm trying to copy a file that is locally stored on the hard drive ( C : \ ) to a folder stored on a connected smartphone device via USB.The folder `` path '' is represented using friendly names as MyPCName\MyName\Card\Android in the Explorer navigation bar , and as : : { 20D0... | Which Win32 function must I use to copy a file to a smartphone folder ? |
C_sharp : C # 5.0 Language Specification 7.6.10.2 Object initializers states that A member initializer that specifies an object initializer after the equals sign is a nested object initializer , i.e . an initialization of an embedded object . Instead of assigning a new value to the field or property , the assignments i... | C # nested object initializer |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.