text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : This is best illustrated with an example.Say I want to load several records from a database at the beginning of a web request . I want to pull in all the necessary data asynchronously . I might have something like this : Now let ’ s say I want to load this data in parallel . Suddenly this nice clear/clean asy... | What is the most elegant way to load multiple variables asynchronously in parallel in c # |
C_sharp : I was trying around a bit with Try Roslyn when I entered this piece of code : And it gave me back this code : What I do n't get is why it would do the assignment of the backing field twice inside of the constructor : Is this an error of the website or does the Roslyn compiler actually do this ( would be reall... | Why does the IL set this value twice ? |
C_sharp : I am working on a web application . I have two text boxes , one is txtEmployeeID , and one is txtEmployeeName . What I am trying to do here is when the user enter EmployeeID in the txtEmployeeID , the name of the employee will show up in the txtEmployeeName . I got this part working so far . However , if the ... | How to ignore integer start with 0 |
C_sharp : Author post-edit : Chosen solution ( Original question remains below this box ) SUMMARY : You SHOULD NOT name a class the same as its namespace . Therefore should a product name be used for the namespace or the main class ? Chosen solution : I decided to apply the product name to the namespace and add a suffi... | Product trademark name begs for class/namespace with same name |
C_sharp : Why is it giving me a null in s variable ? I know that casting it using int ? s = ( int ? ) i ; will work fine but why ca n't I use an as operator ? <code> long ? i = 10000 ; int ? s = i as int ? ; | Why ` as ` is giving null for nullable value types ? |
C_sharp : This question is a slightly modified version of Convert List < T > to Dictionary with strategyI have List < DTO > where DTO class looks like this , I create objects and add it to List.Now my requirement is I need to create a List from the dtoCollection where Name field should be unique across the entire List.... | Group a List based on uniqueness |
C_sharp : Hi I have a listbox Whenever a user selects an item a request is sent to the web Now I want to cancel the previous operation when the user selected the item and then start the new operation.I used the following codes to do this , I wanted to know if these codes work well . Or should I try another way ? and i ... | Cancel Task in async void |
C_sharp : Using Visual Studio 2013 , I 'm trying to reproduce the gotcha mentioned in Eric Lippert 's blog post `` Closing over the loop variable considered harmful '' .In the project properties , I selected `` C # 3.0 '' as the language version ( Build > Advanced… ) . Further , I selected `` .NET Framework 3.5 '' as t... | Reproducing the `` close over the variable of a foreach '' gotcha |
C_sharp : Imagine that you have a list called List < Foo > .Foo is an abstract class , so this can be FooA , FooB , FooC or FooD . And I 'd like to have an extension for List < T > where you can order this elements by type but sequently.For example , if I have 9 elements in it.Order by type sequently will be.I 'm tryin... | How to order a list by type ? |
C_sharp : This has me pretty stumped . Maybe I 'm too tired right now.inputArea is a nullable Rectangle , which in my particular case is null.The first two statements yields a cropArea initialized to 0 . The second , however , yields the correct cropArea based on the image width and height . Have I misunderstood anythi... | Weird behaviour with conditional operator in .Net |
C_sharp : I have the following code : I would like my listSrc result to contain two Info items whose Name and Num properties are : However , the code I show above results in four items : <code> public class Info { public string Name ; public string Num ; } string s1 = `` a , b '' ; string s2 = `` 1,2 '' ; IEnumerable <... | Split multiple strings into a list of objects in C # |
C_sharp : Is there a way to reliably get a unique e-mail address from one put in from a user ? The problem is services such as GMail allow you to put a period in the address and it 's stripped out whereas with other services this is not the case.GMail : All of these are the sameOther service : These are unique.Other th... | How to de-duplicate e-mail addresses |
C_sharp : How can this code : run 3x faster than this code : The first code snippet does exactly the same fast divide operation ( thats the multiply then shift right ) but also a subtraction and multiplication but but the JIT compiler appears to be producing slower code.I have the disassembly code for each available.Th... | How can the first of these two code snippets run 3x faster than the second when its doing more work ? |
C_sharp : Using interpolated strings to send sql server queries , why with a datacontext on LINQ to SQL you need to add single quotes ? db.ExecuteCommand ( $ '' delete table where date = ' { date : yyyy-MM-dd } ' '' ) ; while with EF Core you need to remove them ? and why in EF Core , if you 're using String.Format ins... | Ef Core vs Linq on interpolated string |
C_sharp : So insteed of writing : I thought of writing : It kind of feels wrong , especially this part `` obj.Collection = obj.Collection ... '' What do you guys think ? Regards , <code> if ( obj.Collection == null ) obj.Collection = new Collection ( ) ; obj.Collection.Add ( something ) ; obj.Collection = obj.Collectio... | What 's wrong with the ? ? operator used like this : |
C_sharp : This code seems to not call the Mixed constructor and prints y = 0However , simply modifying the Main function to look like this results in the constructor being called.This prints : Why does simply adding this reference to a non-static field result in the constructor being called correctly ? Should n't creat... | Why is n't this C # instance constructor being called , unless there is a reference to a non-static member ? |
C_sharp : I am iterating through a collection in a foreach loop and was wondering.When this gets executed by the .NET runtimeDoes the myDict.Values get invoked for every loop or is it called only once ? Thanks , <code> foreach ( object obj in myDict.Values ) { // ... do something } | Collections use in foreach loop |
C_sharp : This is best illustrated with an example : I want to tell , for an arbitrary object , if I can cast it to Cat . Sadly I can not seem to use the is/as operator.I 'm hoping to avoid a try/catch ( InvalidCastException ) as I may be doing this a lot and this would be quite expensive.Is there a way to do this chea... | Is there a `` cheap and easy '' way to tell if an object implements an explicit/implicit cast operator to a particular type ? |
C_sharp : Here is the codeI can´t get the limit counter to increment for each timeI can get it to count to 1 between each outputline , but that´s itAny idea why ? I want it to be able to count every `` overshoot '' <code> class Actuator { private int limit_count = 0 ; public int Inc_Limit_counter ( int temp , int co2_c... | Displaying values from a private int in c # |
C_sharp : UPDATE : The following code only makes sense in C # 4.0 ( Visual Studio 2010 ) It seems like I am having some misunderstanding of covariance/contravariance thing . Can anybody tell me why the following code does n't compile ? while this one compiles : ( ! ! ! ) <code> public class TestOne < TBase > { public I... | Covariance/contravariance : how to make the following code compile |
C_sharp : In specific , if I say : How does the compiler go about generating a concrete enumerable class out of this ? <code> public static IEnumerable < String > Data ( ) { String connectionString = `` ... '' ; using ( SqlConnection connection = new SqlConnection ( connectionString ) ) { connection.Open ( ) ; IDataRea... | How does the compiler use 'yield return ' to build a class |
C_sharp : I am making a horse programme . I have the horse face and wish to apply a bit mask . Only the horses eyes should be visible when it is wearing the bit mask . First I must convert the horses face to digital . For this I have a set of bits which include 0 , 0 , 0 , and 1 for the face of the horse.I am using C #... | Can not apply bit mask |
C_sharp : I 've written a recursive function which yields IEnumerable < int > So If I write It should yield But it does n't work as expected . ( it displays 0 ) .In normal recursive function ( which return int - without Ienumerable ) it works fine.Question : How can I fix the code so it yields the expected value ? nb .... | Recursive IEnumerable does n't work as expected ? |
C_sharp : I am trying to upgrade my project from Microsoft.WindowsAzure.Storage v9 ( deprecated ) to latest sdk Azure.Storage.Blobs v12.My issue ( post-upgrade ) is accessing the ContentHash property.Pre-upgrade steps : upload file to blobget MD5 hash of uploaded file provided by CloudBlob.Properties.ContentMD5 from Mi... | ContentHash is null in Azure.Storage.Blobs v12.x.x |
C_sharp : When trying to compile the following code in LINQPad : I get the following error : The type arguments for method 'System.Linq.Enumerable.Select ( System.Collections.Generic.IEnumerable , System.Func ) ' can not be inferred from the usage . Try specifying the type arguments explicitly.If I use a lambda like d ... | Why generic type inference does n't work in that case ? |
C_sharp : In my viewmodel , I have a list of items I fetch from the database and then send to the view . I would like to know if it 's possible to avoid having to refill the options property whenever I hit a Post action and need to return the model ( for validation errors and what not ) ? In webforms , this would n't b... | Reuse model data in a post action |
C_sharp : I have created a bezier curve by adding the following script to an empty game object in the inspector . This draws to complete curve at once when I run the code . How can I animate it over a given period of time , say 2 or 3 seconds ? <code> public class BCurve : MonoBehaviour { LineRenderer lineRenderer ; pu... | How to animate a bezier curve over a given duration |
C_sharp : This is my first question on Stack Overflow . Apologies in advance if I do n't do things quite right while I 'm learning how things work here.Here is my code : It produces this XML : I do n't understand why I am not getting < Items testAttribute= '' foo '' > Please can anyone tell me what I need to add to my ... | C # XML Serializer wo n't store an attribute |
C_sharp : I 'm having a hard time getting the LINQ-syntax.. How can I do this command in a better way ? As you can see , there 's a table user , a table pintouser and a table pin . Pintouser references user and pin . Is it possible to write something short like `` user.pintouser.pin '' ? I think I have the navigation p... | Making a LINQ query better |
C_sharp : I have this code after decompileI do n't know what mean operator/symbol < > before some operations . Does somebody know ? <code> SampleClass sampleClass ; SampleClass < > g__initLocal0 ; int y ; sampleClass = null ; Label_0018 : try { < > g__initLocal0 = new SampleClass ( ) ; < > g__initLocal0.X = 5 ; < > g__... | What does the symbol < > mean in MSIL ? |
C_sharp : Basically I have a few functions that look like this : Under the assumption I can use the same resource instead of a different one [ instance ] in every function is it ok practice in regard to cleanup and such to do this ? : <code> class MyClass { void foo ( ) { using ( SomeHelper helper = CreateHelper ( ) ) ... | Using statement in every function - > convert to class field with proper cleanup ? |
C_sharp : I have a class hierarchy like thisI wanted to create an action Action lamda that had a generic type paramater of type CalendarEventBase that I could assign to the following different methods : I created the following illegal assignment : The compiler complains that it was expecting a method with void ( Calend... | Contravariance in Action lambda - C # |
C_sharp : Normally if I would have had this : I would have gotten a CA1062 : Validate arguments of public methods from code analysis . It would have been fixed by modifying the code as such : But now I want to use another means of doing this validation : since the method validates the argument the code analysis rule is... | How to let Code Analysis pick up that an argument was validated in called method |
C_sharp : Goal : Generic enumerated type to be the same type when returned.Note : This works when the types are entered but I do n't understand why they ca n't be inferred.List < T > then return List < T > IOrderedEnumerable < T > then return IOrderedEnumerable < T > ETCCurrent method ( works only if all types are ente... | How can I return < TEnumerable , T > : where TEnumerable : IEnumerable < T > |
C_sharp : I 'm trying to downcast a controller instance inside an action filter , and I 'm having issue doing so.I have a DefaultController class : IBaseEntity is : I have an instance of a controller , inheriting the DefaultController : Workflow is inheriting BaseEntity which implements IBaseEntity.Now , inside my acti... | How to do this tricky down-casting with generic constraints ? |
C_sharp : I 've noticed something very odd when working with addition of nullable floats . Take the following code : result is 6.099999 whereas result2 is 6.1 . I 'm lucky to have stumbled on this at all because if I change the values for a , b , and c the behavior typically appears correct . This may also happen with ... | Curious Behavior When Doing Addition on Nullable Floats |
C_sharp : Want to learn how an instance of a class is created in the background . When this statement is evaluated . What will happen in the backgroud ? My following statements are correct or not ( for 32-bit OS machine ) ? A memory space will be created and referenced as myClass ; within above memory space , 4 bytes i... | How does C # create an instance of a class ? |
C_sharp : Suppose I have the following array ( my sequences are all sorted in ascending order , and contain positive integers ) I want to write a linq query to select the continuous numbers in a series treated as a group . So , in above example I would get { [ 1 , 2 , 3 ] , [ 7 , 8 , 9 ] , [ 15 , 16 , 17 ] } .I could w... | LINQ Query to identify fragments in a series |
C_sharp : I created an Class which is only able to handle primitive ( or ICloneable ) TypesI want to know if it 's possible to say something like : or do I really need to create a constructor for each primitive type like : What I am trying to achieve is to create an object with 3 public properties Value , Original and ... | How to tell a constructor it should only use primitive types |
C_sharp : If I have a string like thisHow can I parse it such that the result would be three string `` words '' which have the following content : Edit 2 : note that the quotation marks are to be retainedAt first , I attempted by using string.Split ( ' ' ) , but I noticed that it would make the third string broken to f... | Parse string with whitespace and quotation mark ( with quotation mark retained ) |
C_sharp : I have dimensional list : I would do binary search by the first column ( words ) , something like this : but it works only for a one-dimensional list . How would I extend it to work for two-dimensional lists in my case ? I do n't want to use Dictionary class . <code> List < List < string > > index_en_bg = new... | BinarySearch in two dimensional list |
C_sharp : My Question is simpleVB.dll ( VB5.0 I guess ) includes these methodsin C # ... . ( .NET 4.5 ) The first one works great , but the second one spilt this error . A call to PInvoke function 'ffr_data_transceive_ex ' has unbalanced the stack . This is likely because the managed PInvoke signature does not match th... | VB5 dll , how can I invoke the function from C # ( .NET 4.5 ) |
C_sharp : Here 's what I am trying to write : The signature of the Bar ( ) method is : So I get a compile error because the T in Foo 's signature does n't have the same constraint . Unfortunately I ca n't write : because Foo is implementing a method defined in an external interface . Question is : Can I somehow transpo... | How to cast a generic parameter ? |
C_sharp : I have a windows TCP service , which has many devices connecting to it , and a client can have one or more devices.Requirement : Separate Folder per client with separate log file for each device.so something like this : Now I have not used a 3rd Party library like log4net or NLog , I have a class which handle... | Separate Logfile and directory for each client and date |
C_sharp : In C # , volatile keyword ensures that reads and writes have acquire and release semantics , respectively . However , does it say anything about introduced reads or writes ? For instance : <code> volatile Thing something ; volatile int aNumber ; void Method ( ) { // Are these lines ... var local = something ;... | Does volatile prevent introduced reads or writes ? |
C_sharp : I 'm refreshing my memory on how reference and value types work in .NET . I understand that the entry on the stack for a reference type contains a pointer to a memory location on the heap . What I ca n't seem to find details about is what else the stack entry contains . So , given the following : After the fi... | What does the stack entry for a reference type contain ? |
C_sharp : Given an Expression < Func < TEntity , bool > > along the lines ofI am trying to extract a list property conditions by type , i.e.So far , I have created an ExpressionVisitor and identified the VisitBinary method as the one I want to plug into in order to obtain my information.I am still at a loss abouthow to... | Extract all conditions from Expression by Type |
C_sharp : UPDATE : I 've found the answer , which I will post in a couple of days if nobody else does.I am creating a numeric struct , so I am overloading the arithmetical operators . Here is an example for a struct that represents a 4-bit unsigned integer : The overloaded addition operator allows this code : Here , th... | Overloading the + operator so it is sensitive to being called in a checked or unchecked context |
C_sharp : I am very new to programming and I have a question , I am trying to use Regex method to extract hours , minutes and seconds from a string and putting them into an array , but so far I can do it with only one number : How do manage to read from a string 06 : 11 : 33 , and transform these hours , minutes and se... | Regex extract from string xx : xx : xx format |
C_sharp : I have developed a small-ish C # console application ( TextMatcher.exe ) on my local development machine and now need to deploy it to the live environment . It references another class library which I developed which has generic functions , which I intend to use and improve in future console applications.Ulti... | C # application says `` No '' when executed |
C_sharp : I need to split List < IInterface > to get lists of concrete implementations of IInterface.How can I do it in optimal way ? <code> public interface IPet { } public class Dog : IPet { } public class Cat : IPet { } public class Parrot : IPet { } public void Act ( ) { var lst = new List < IPet > ( ) { new Dog ( ... | C # split List of interface by implementations |
C_sharp : I have a predicate Expression < Func < T1 , bool > > I need to use it as a predicate Expression < Func < T2 , bool > > using the T1 property of T2 I was trying to think about several approches , probably using Expression.Invoke but couln ; t get my head around it.For reference : AndThanks a lot in advance . <... | Linq - Creating Expression < T1 > from Expression < T2 > |
C_sharp : I read of a useful trick about how you can avoid using the wrong domain data in your code by creating a data type for each domain type you 're using . By doing this the compiler will prevent you from accidentally mixing your types.For example , defining these : allows me to not mix up meters and seconds becau... | Is there any way to implicitly construct a type in C # ? |
C_sharp : consider the following code : //This prints 53954 . Why ? ? and //This prints 40000 . how ? ? any help appreciable ... <code> ushort a = 60000 ; a = ( ushort ) ( a * a / a ) ; Console.WriteLine ( `` A = `` + a ) ; ushort a = 40000 ; a = ( ushort ) ( a * a / a ) ; Console.WriteLine ( `` a = `` + a.ToString ( )... | confusion with result of Ushort |
C_sharp : I have static method like this : and I use it as following : How write method that return the following results ? s1 : `` ID '' s2 : `` Age '' s3 : `` Name '' * return each property ` s name after = > as string <code> public static string MyMethod ( Func < Student , object > func ) { return ? ? ? ; } var s1 =... | How Func < DomainObject , object > return Object name as string |
C_sharp : In C # resizing an array ( increasing its size in this case ) initializes the new segment with default values – is this reliable ? I do see the default values ( 0 for byte arrays ) , but is it possible to safely take that as the standard behavior for all base types ? In my application saving every second is a... | In C # resizing an array ( increasing its size in this case ) initializes the new segment with default values – is this reliable ? |
C_sharp : I have been looking into speeding up my application as it is performance critical ... i.e . every millisecond I can get out of it is better . To do this I have a method that calls some other methods and each of these other methods is wrapped with a Stopwatch timer and Console.WriteLine calls . I.e . : The pro... | Console.WriteLine speeds up my code ? |
C_sharp : In C # , you can do something like this : What is this syntax called ? <code> SomeClass someClass = new SomeClass ( ) { SomeProperty = someValue } ; | What is the name of this C # syntax ? |
C_sharp : In the below example I have created a class named 'Custom ' that implements IComparable : Implementations of CompareTo ( Object ) are generally `` forgiving '' in that they will cast 'value ' to a more specific type . In this case , a cast to the type 'Custom ' will be performed so a comparison can be made . ... | How to handle operator == overload when the right hand side is of type Object |
C_sharp : I came across this and am curious as to why is it not possible to use the is operator to discern between bool and Nullable < bool > ? Example ; Calling Main ( ) gives ; I 'd expect ; Why do both bool and Nullable < bool > match each other ? What have I tried ; I 've consulted the docs for Nullable , is , swit... | Why is it not possible to use the is operator to discern between bool and Nullable < bool > ? |
C_sharp : I have a problem with generic . When I try to use less operators in generic , their call is not happening . But it works with the method Equals.That is a some test class : And class Checker : Small testing : How I can use less operators in class Test from generic ? <code> public class Test { public int i ; st... | C # generics class operators not working |
C_sharp : I have people and places data as : Person entity hasIList < DateRangePlaces > each havingIList < Place > of possible places Schedule day pattern as ie . 10 days available 4 unavailableWithin a particular DateRangePlaces date range one has to obey to Schedule pattern whether person can go to a particular place... | Advanced : How to optimize my complex O ( n² ) algorithm |
C_sharp : I frequently find myself wanting to do something along these lines : Of course the compiler will now complain that this code is not valid , since ClientSize is a property , and not a variable.We can fix this by setting the ClientSize in its entirety : Or , in general : But this is all looks unnecessary and ob... | Why can we not set properties of properties ? |
C_sharp : I think I 'm going mad , someone please reassure me.People keep on adding code like the above in to our code base , surely this is wrong and horrid and I am doing the world a favour by deleting it and replacing all ( or both in this case ... ) references to it with the internal code.Is there any real justific... | Methods which wrap a single method |
C_sharp : I 'm an absolute beginner when it comes to C # . Trying to learn via examples . So I 've found myself a nice little calculator tutorial . Everything goes fine up to last moment , the code is working , but it does n't take multi-digit input like 33 . There 's a bool statement there for turning arithmetic opera... | C # bool statement throws strange exception for seemingly unconnected double.parse ( string ) |
C_sharp : I would like to have four buttons like this : On an iPhone or a small mobile I would like to have these fill 90 % of the screen width . But on a bigger screen I would like the buttons to only fill 50 % of the screen width . Can anyone suggest to me how I can do this ? <code> < Grid x : Name= '' buttonGrid '' ... | How can I achieve four spaced buttons on an iPhone that fill the screen and on bigger than an iPhone that fill half the screen ? |
C_sharp : How to match the sentence that start with `` أقول `` by this code ? This is an arbic word . `` أقول `` What is the regular expression exactly ? <code> Regex.Matches ( Content , `` أقول `` ) ; | How to match the sentence that start with `` أقول `` by this code ? |
C_sharp : I have a DataTemplate Column with 2 DatePickers that are bound to 2 properties . When the data in these control is changed only last control gets updatedIn this case if I update both Start and Due Only Due gets updated . Also the binding works fine because if I put a breakPoint on Start in my Model class it g... | Only last control in Data Template column getting updated |
C_sharp : I have 2 scenarios.This fails : error CS0102 : The type ' F < X > ' already contains a definition for ' X ' This works : The only logical explanation is that in the second snippet the type parameter X is out of scope , which is not true ... Why should a type parameter affect my definitions in a type ? IMO , f... | 'Lexical ' scoping of type parameters in C # |
C_sharp : I want to see the real time use of Volatile keyword in c # . but am unable to project the best example . the below sample code works without Volatile keyword how can it possible ? In the above code i am getting a value as 5. how it works without using volatile keyword ? <code> class Program { private static i... | What is the volatile keyword purpose in c # ? |
C_sharp : BackgroundI have a website that displays data unique to a client . The site required views to be created ever time a new client is added . Each client is unique and has a different identifying information unique to them . For example an ID number and a prefix.Everytime a new client is added a new set of views... | How to Dynamically Create Views ? |
C_sharp : I 'm using structure map with the AspNet Core 1.0 RTM . It appears they have removed using the FromServices attribute on properties . This breaks the code below because I am now unable to inject the ClaimsPrincipal . I 'm not sure how to get the DI system to pickup this property . Do I need to create a custom... | Asp.Net Core RC1 - > RTM DI changes - Removed FromServices |
C_sharp : I 'm currently working on an application that combines many streams of data through equations . What I 'd like to be able to do is something like : Where result updates whenever any of the streams update . At the moment the only way I can express this in Rx is as : Which is n't nearly as clear.My current idea... | Stream Arithmetic with Reactive Extensions |
C_sharp : I have a List of type string in a .NET 3.5 project . The list has thousands of strings in it , but for the sake of brevity we 're going to say that it just has 5 strings in it.Assume that the list is sorted ( as you can tell above ) . What I need is a LINQ query that will remove all strings that are not dupli... | Query a list for only duplicates |
C_sharp : I have subscribed various event in OnNavigatedTo like I have n't unsubscribed this event . Does it cause any memory issue when this page is not needed ? ? <code> protected override void OnNavigatedTo ( NavigationEventArgs e ) { Loaded += Screen_Loaded ; } | Do I need to unsubscribe from an event in a c # metro application ? |
C_sharp : I am trying to pull multiple elements out of an XML documents and their children but I can not find a useful example anywhere ... MSDN is very vague . This is c # in .NetI am creating this XML dynamically already and transferring it to a string . I have been trying to use XmlNode with a NodeList to go through... | Can I get a specific example of XML in c # |
C_sharp : EDIT : The bounty 's expired , but if the community would like to award it to someone , then I choose Raful Chizkiyahu.I have a memory leak in one of my C # Winforms programs , and I 'd like to graph its memory usage over time to get a better understanding of what might be causing the leak . Problem is , none... | Contradictory reporting of total Process memory usage in C # Winforms app |
C_sharp : I 'd like to know how should I do to test simple C # expressions 1 ) in Visual Studio and 2 ) not in debug , in design mode Say , I want to verify what will return this codeOr I obtained in the immediate window the following message : <code> ? DateTime.ParseExact ( `` 2016 '' , `` yyyy '' ) int i ; int.TryPar... | Test simple c # code expressions in Visual Studio |
C_sharp : If I execute the code below , OutOfMemoryException occurs at either the lineor the linewhen the inner for statement executed about 1000 times.However , I do n't know why OutOfMemoryException occurs . I think I have written enough using to dispose Bitmap objects . Where does the memory leak occurs ? EDIT : OK.... | C # Bitmap - Can not find how to remove OutOfMemoryException |
C_sharp : I am writing some unit test for an ApiController . I continue to get multiple System.MissingMethodException exceptions for methods in the System.Web.Http namespace . Message : System.MissingMethodException : Method not found : 'System.Net.Http.HttpRequestMessage System.Web.Http.ApiController.get_Request ( ) '... | System.Web.Http methods missing in Nunit test project |
C_sharp : I encountered a weird problem : given such string { `` text '' : '' s '' , '' cursorPosition '' :189 , '' dataSource '' : '' json_northwind '' , which is not a correct json , it still gets succesfully parsed.this is the class : Here is test that surprisingly succeeds : does the library have some loosened pars... | Newtonsoft.Json parses incorrect json |
C_sharp : In a project I 'm currently working on , I am starting an external process . However , the external process is the EXE of a complex program which loads current-user information from a user folder . The desktop shortcut for the program resolves the matter by setting the `` Target : '' parameter to X : \exepath... | More than one important path for .NET Process |
C_sharp : I have the following line of code : Which results in an IOException being thrown . Additional information : The process can not access the file ' C : \Users\Username\AppData\Local\Temp\dgl5fb1i.err ' because it is being used by another process.However , this is a part of a large program that consumes more tha... | IOException when dynamically compiling code |
C_sharp : What happens exactly during string initialization ? Is it going to make a call to any of these constructors ? <code> string s = `` Hello World ! `` ; public String ( char* value ) ; public String ( char [ ] value ) ; | What happens during string initialization ? |
C_sharp : C # has a conditional operator and IF statements and I suspected that the conditional operator would be just syntactic sugar . So at compile time it would have a the same as an IF operation . However they do not ( see below ) , they do have different IL . Trying to wrap my head around it and the assumption I ... | Why such a difference in IL between IF and the conditional operator ? |
C_sharp : The two methods above seems to behave equally , both when passing null reference or boxed T value . However , the generated MSIL code is a bit different : vsAs you may see , the o is T ? expression actually performs type check for Nullable < T > type , despite the fact that nullable types are specially handle... | Is there a difference between ` x is int ? ` and ` x is int ` in C # ? |
C_sharp : I found a piece of code of the following form : In other parts of the code , I want to get the same lightweight CustomerContact object , only not from the Invoice , but from the Customer itself . So the obvious thing to do would be to have : and then change the Expression taking Invoice as input to refer to t... | Syntax to refer a method returning an Expression to another method ? |
C_sharp : Is it possible to use the return value of a function instead of a specific value as optional parameter in a function ? For example instead of : I want something like <code> public void ExampleMethod ( int a , int b , int c=10 ) { } private int ChangeC ( int a , int b ) { return a+b ; } public void ExampleMeth... | Use a function to define an optional parameter |
C_sharp : I have this code that creates a request and reads the data but it is always emptyWhen i try to access the link from browser i get this json : what am I missing ? <code> static string uri = `` http : //yiimp.ccminer.org/api/wallet ? address=DshDF3zmCX9PUhafTAzxyQidwgdfLYJkBrd '' ; static void Main ( string [ ]... | Reading data from url returns empty value |
C_sharp : Hi i am new in c # and i want to ask how to write this code more pretyAll it do just copy all properties except id . Can i write it shortly ? Thanx and sorry for my bad english <code> public void Update ( Product pr ) { Product prod = GeProductById ( pr.ProductID ) ; prod.Name = pr.Name ; prod.Count = pr.Coun... | How to write it pretty ? |
C_sharp : I wrote this piece of code : and the reflector gives me : Obviously , this is not what the original code says . The line ( this._queue = new Queue < int > ( 10 ) ) ; will alway return a new Queue < int > ( 10 ) instead of _queue when it is not null.Is this a bug in the .NET Reflector or am I missing something... | Is the .NET Reflector unable to reflect over the null-coalescing operator correctly ? |
C_sharp : In `` Getting Started with Asynchronous Programming in .NET '' by Filip Ekberg , in the `` Asynchronous Programming Deep Dive/Working with Attached and Detached Tasks '' chapter , he says that by using the service value inside the async anonymous method , it introduces a closure and unnecessary allocation : N... | What is the allocation being saved here ? |
C_sharp : By calling Push ( ) and Pop ( ) an instance of Stack < T > in a single line I get a different behavior than performing the imho same code in two lines.The following code snippet reproduces the behavior : The Element class is really basic : With this code I get the following result ( .NET 3.5 , Win 7 , fully p... | Unexpected operation order in Stack < T > related one liner |
C_sharp : I have the following C # code trying to benchmark under release mode : I am on a 64-bit machine and VS 2015 installed . When I run the code under 32-bit , it runs each iteration around 0.6 seconds , printed to the console . When I run it under 64-bit then the duration for each iteration simply jumps to 4 seco... | Slow execution under 64 bits . Possible RyuJIT bug ? |
C_sharp : Following this very interesting issue which was originated from this question -I want to take 1 steps back please ( removed the dynamic environment ) : Looking at this code : ( a variant of this one ) The result is : This is understood : The x = 1 is from the method itself ( using Console.Writeline ) in bool ... | & & operator overloading and assignments in C # - Clarification ? |
C_sharp : First my question , and then some details : Q : Do I need to stub the value of a property when making sure its value is used in a subsequent assignment ? Details : I 'm using Rhino Mocks 3.5 's AAA syntax in MSpec classes . I 've trimmed the code below to keep it ( hopefully ) easy to grok . *Not Stubbing _fo... | Rhino Mocks : stubbing value used in assertion ? |
C_sharp : Let 's say I have the following input : and expect the following output : The logic is a square which needs to be turned by 90 degrees to the right - but without linebreak.The width should be dynamic and always Is there a easy approach to solve this ? <code> string input = `` 123456789 '' ; string output = ``... | Sort a string by Linq |
C_sharp : On occasion we get some robots that like to post bad information to our website ( they are attempting some kind of reflection attack ) but luck for us the attempts are stopped via the default input validation that one gets with MVC.This is nice and all , but now we want to see what the robots are actually sen... | MVC see input that caused exception |
C_sharp : Below is a console app that demonstrates the issue : Output is `` False True True '' .I 've used SOS.dll to try to find what holds the delegates from being GCed and here is what I get for the Action : Can someone explain what is going on ? <code> class Program { static void Main ( ) { InitRefs ( ) ; GC.Collec... | Delegates do not get garbage collected |
C_sharp : I am trying to change the Background of some errorneous data containing cells in a WPF DataGrid by using this code : However , upon doing this , the above change of background-color change is occuring to cells in the same column , periodically after every 14 ( aprox . ) rows as I scroll down the DataGrid . It... | Changing a cell in a row of a DataGrid ( WPF ) is changing cells in rows below |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.