text
stringlengths
46
37.3k
title
stringlengths
12
162
C_sharp : I need to develop a fairly simple algorithm , but am kindof confused as how to best write a test for it.General description : User needs to be able to delete a Plan . Plan has Tasks associated with it , these need to be deleted as well ( as long as they 're not already done ) .Pseudo-code as how the algorithm...
How would I go about unit testing this ?
C_sharp : In a heavily multi-threaded scenario , I have problems with a particular EF query . It 's generally cheap and fast : This compiles into a very reasonable SQL query : The query , in general , has optimal query plan , uses the right indices and returns in tens of milliseconds which is completely acceptable.Howe...
Curious slowness of EF vs SQL
C_sharp : I have the following method in my custom WebTest : On my GetRequestEnumerator I am calling the method like this : Note : The original code is more complicated than this , but it is irrelevant.This is working fine when running the load test on my local machine : You can see that each request is being identifie...
WebTestRequest.ReportingName is ignored when using VS Team Services
C_sharp : They use StructureMap for IoC where I am currently working.I have an application class that will implement multiple properties of the same interface ... and I need to bind DIFFERENT IMPLEMENTATIONS ... and no , I can not do this : IProvider < T > FOR INSTANCE : In Unity , there are many ways to do this , for ...
How Do I Bind Different Concretes to a Property Using StructureMap
C_sharp : I am deserializing an Object using this codeMy UserData class is as followsWhen it deserializes I get an object returned as if I had just called new UserData ( ) but if I remove the : BindableBase from the class definition it deserializes correctly . I guess this is because the base class contains some proper...
Deserializing JSON produces default class
C_sharp : I was wondering ... When I have a code like this : Can MyAgent contain code that recognizes it is running under a lock block ? What about : Can MyAgent contain code that recognizes it is running under a loop block ? The same question can be asked for using blocks , unsafe code , etc ... - well you get the ide...
Under what context am I running in C # ?
C_sharp : I have a category/file tree structure . Both categories and files can have parents , so I derived them from a common base class that has a Parent property . Since all parents will obviously always be categories ( files ca n't be a parent ) , it seems to make sense to make the Parent property of the node be th...
Is it bad form to refer to a derived type in a base type ?
C_sharp : My understanding is that LINQ IEnumerable extensions are supposed to call Dispose on the IEnumerators produced by the IEnumerable . See this answer on SO . However , I 'm not seeing that in practice . Is the other SO answer incorrect , or have I found a bug in LINQ ? Here 's a minimal reproduction of the issu...
LINQ is n't calling Dispose on my IEnumerator when using Union and Select , expected behavior or bug ?
C_sharp : I would like to know if it is possible to remove an IDictionary item by its key and in the same time get its actual value that has been removed ? Examplesomething like : Output <code> Dictionary < string , string > myDic = new Dictionary < string , string > ( ) ; myDic [ `` key1 '' ] = `` value1 '' ; string r...
IDictionary How to get the removed item value while removing
C_sharp : In javascript , it is common to use closures and create then immediately invoke an anonymous function , as below : Due to strong typing , this very verbose in C # : Is there a more elegant way to go about this type of thing in C # ? <code> var counter = ( function ( ) { var n = 0 ; return function ( ) { retur...
Invoking Lambdas at Creation
C_sharp : I do n't understand the difference between Anonymous Class and object Classif i have an anonymous type object : i can see how i can iterate through it and get values of the properties doing this x.name ... but if i change this to an object then if i loop through it i will not be able to access the properties ...
what is the difference between Anonymous Class Array and Object Array ?
C_sharp : This has probably been already asked but it 's hard to search for.What is the difference between [ Something ] and [ SomethingAttribute ] ? Both of the following compile : Are there any differences between these apart from their appearance ? What 's the general guideline on their use ? <code> [ DefaultValue (...
What 's the difference between [ Something ] and [ SomethingAttribute ]
C_sharp : I 'm trying to design a class that exposes the ability to add asynchronous processing concerns . In synchronous programming , this might look likein an asynchronous world , where each concern may need to return a task , this is n't so simple . I 've seen this done lots of ways , but I 'm curious if there are ...
Pattern for delegating async behavior in C #
C_sharp : Comparing `` î '' With `` i '' Current culture was en-GB . I would expect all of these to return 1 . Why does having a longer string change the sort order ? <code> string.Compare ( `` î '' , `` I `` , StringComparison.CurrentCulture ) -- returns -1string.Compare ( `` î '' , `` I `` , StringComparison.CurrentC...
Weird string sorting when 2nd string is longer
C_sharp : I had to reinstall everything on my computer including Visual Studio , my question is , before I reinstalled Visual Studio was showing the code on my C # programs in a method using Unicode operators for example : instead of However upon reinstalling Visual Studio they 've reverted back to the text format , do...
Visual Studio a way to show operators as opposed to text Example : ≠ instead of ! =
C_sharp : Foreword : I am trying to describe the scenario very precisely here . The TL ; DR version is 'how do I tell if a lambda will be compiled into an instance method or a closure ' ... I am using MvvmLight in my WPF projects , and that library recently changed to using WeakReference instances in order to hold the ...
Determining when a lambda will be compiled to an instance method
C_sharp : My problem isi have this JSON file : and i have to save it in a list but when i try to print the first element of the list I get a System.ArgumentOutOfRangeException , as if my list is empty . this is my code : and these are my two class for the saves : and can you help me solve it ? <code> JavaScriptSerializ...
Deserializing a JSON file with c #
C_sharp : I seem to be having trouble executing a lambda expression that I 've previously assigned to a variable . Here 's a small C # example program I 've put together : I want it to produce this output:3 2 5 8 1 4 7 9 61 2 3 4 5 6 7 8 99 8 7 6 5 4 3 2 1But , confusingly , it produces this output:3 2 5 8 1 4 7 9 63 2...
Assigning a lambda expression causes it to not be executed later ?
C_sharp : I 'm working on a prototype EF application , using POCOs . Mainly as an introduction to the framework I 'm wondering about a good way to set up the application in a nice structure . Later on I 'm planning to incorporate WCF into it.What I 've done is the following:1 ) I created an edmx file , but with the Cod...
Setting up an EF application 's structure
C_sharp : I need to perform multi string replacement . I have a string where several parts need to be changed according to substitution map.All replacement must be done in one action - it means if `` a '' should be replaced with `` b '' and also `` b '' must be replaced with `` c '' and input string is `` abc '' , the ...
Fast multi-string replacement
C_sharp : I have two IEnumerables of different types , both of which derive from a common base class . Now I try to union the enumerables to get an enumerable of the base class . I have to explicitly cast one of the enumerables to the base class for this to work.I would have guessed that the Compiler would have automat...
Why cant the compiler resolve the resulting type ?
C_sharp : Is there a way to control access to methods to certain roles in .net . Like I 'm using windows authentication only for retrieving user names and nothing more.User roles are maintained in a different application . I think it 's possible through attributes but I 'm not really sure how <code> class A { //should ...
Controlling access to methods
C_sharp : I 've been looking into Functional Programming lately and wanting to bring some concepts to my C # world . I 'm trying to compose functions to create services ( or whatever you 'd call them ) instead of creating classes with injectable dependencies.I 've come up with a way to partially apply a function ( to h...
Static method signature type arguments and partial application
C_sharp : I am a bit clueless about the next task . I wish to select a text between `` that its inside a tag but not outside of the tag , i.e . a selection inside another selection.I have the next tag : < | and | > and i want to select a text only if its between the `` and between the tags. < | blah blah blah `` should...
Regular expression , selects a portion of text inside other
C_sharp : Given the struct S1 : and an equality test : areEqual evaluates to true , as expected.Now lets slightly change our struct to S2 ( replacing the pointer with a string ) : with an analog test : this evaluates to true as well.Now the interesting part . If we combine both structs to S3 : and test for equality : T...
Unexpected equality tests , Equals ( a , a ) evaluates to false
C_sharp : Suppose I 've a generic method as : Are this.Fun < Feature > and this.Fun < Category > different instantiations of the generic method ? In general , how does the generic method get instantiated ? Different generic argument produces different method , or same method along with different metadata which is used ...
How generic methods gets instantiated in C # ?
C_sharp : I have the following KeyBindings : When I press Ctrl+Shift+S to execute the SaveAs command , it works -- but directly afterwards , the Save command is also executed . Is this caused by my Gesture definitions ? <code> < KeyBinding Gesture= '' Ctrl+S '' Command= '' Save '' / > < KeyBinding Gesture= '' Ctrl+Shif...
How can I ensure that only one KeyBinding command is executed when a keyboard shortcut is used ?
C_sharp : I just wonder how to write a number that has to be expressed as string.For instance : or or or <code> if ( SelectedItem.Value == 0.ToString ( ) ) ... if ( SelectedItem.Value == `` 0 '' ) ... public const string ZeroNumber = `` 0 '' ; if ( SelectedItem.Value == _zeroNumber ) ... if ( Int.Parse ( SelectedItem.V...
BestPractice for conditions with strings and numbers
C_sharp : Excuse the poor wording , but I could n't find a better way to explain it.From my understanding , C # is a WORA language- you can write it on one machine and deploy it on another , because the MSIL is n't compiled until the application is actually run.So then why is it that BitConverter.IsLittleEndian is defi...
Why is BIGENDIAN a directive if it 's not resolved at compile-time ?
C_sharp : I have a custom control that when I drag onto the form , creates the following designer.cs code : I 'd like it ( Visual Studio ) to completely ignore the .Color attribute and leave it be . How can I tell it to do that ? Thank you ! <code> // // colorPickerBackground// this.colorPickerBackground.Color = Color....
How can I tell Visual Studio to not populate a field in the designer code ?
C_sharp : I 'm hunting down a bug in a large business application , where business processes are failing but partially persisted to the database . To make things harder to figure out , the process fails only once every few weeks , with hundreds of thousands successfully processed between every failure . The error frequ...
How to detect that rollback has occurred ?
C_sharp : By abusing the type system in c # , I can create code , where the compiler will enforce a rule , to ensure an impossible operation is not performed . In the below code , its specific to matrix multiplication . Obviously the below is totally impractical/wrong , but are there reasons we cant have something like...
Using generics to enforce valid structure at compile time
C_sharp : Im using this code to Send a Mail with excel attachment from gridview , it works fine for the mail part but the excel attachment is always blank i have already debugged the code and sure that the datasource of the Gridview passes the data it needed to the gridview , it seems that im not rendering the gridview...
Retrieving Blank Excel upon attaching excel in Mail
C_sharp : Feel free to load your guns and take aim , but I want to understand why you should n't do this.I have created a custom class designed to replace any instances of List ( which I use to update XML objects behind them ) : The idea is whenever I add or remove an item from this list my bound events will fire and I...
Custom ( derived ) List < T >
C_sharp : Here is an example of a property I have , coded as simply as possibleThis is verbose ; I would like to make it more concise if possible . The following would be acceptable ... ... but it does n't compile . Keyword 'this ' is not valid in a static property , static method , or static field initializerSo I came...
Lazy property requiring `` this ''
C_sharp : Edit : Solved ! thanks to @ kfinity.AskTom suggests using select /*+ opt_param ( '_optimizer_use_feedback ' 'false ' ) */ at the start of your query to disable the feedback usage . This has fixed the problem for me.tldr : Adding a randomized comment to a query makes it run consistent , removing this comment b...
Oracle query only runs consistently when adding a random comment
C_sharp : This is my very first question after many years of lurking here , so I hope I do n't break any rules.In some of my ASP.NET Core API 's POST methods , I 'd like to make it possible for clients to provide only the properties they want to update in the body of their POST request.Here 's a simplified version of m...
Differentiating between explicit 'null ' and 'not specified ' in ASP.NET Core ApiController
C_sharp : Suppose , we have a very simple class : and we want to make an instance of this class : So , in case of List2 it is ok , using `` = '' we set property . But in List1 case it looks like we set property , but actually , we suppose to set it somewhere before , and here we only set values . And it very similar to...
Weird syntax of collection initializers
C_sharp : I am doing a Func - > Expression - > Func conversion . It works fine if I create the Func < > ( ) from a method ( first example below ) however if I create the function using an expression tree ( 2nd example ) it fails with a NullReferenceException when accessing func2.Method.DeclaringType.FullName . And this...
Is there a way to set 'DeclaringType ' in an expression tree ?
C_sharp : The code below will compile but fails at runtime . It 's provided just to give an idea of what I 'm trying to do . What I would like to do is create a method that accepts a collection of objects ( effectively an `` untyped '' collection ) and if this collect is comprised of numbers of a single type return the...
Is there a clever way to call a type dependent extension method dynamically ?
C_sharp : The above code is copy from Page 153 c # in a Nutshell , I do n't understand why the { } are missing after the using statement , is that a typo in the book ( unlikely ) or just not needed ? As the syntax is that using need to follow by a block of code inside { } .I would expect this code to be : <code> using ...
c # `` using '' statement follow by try statement can the bracket be ombitted in that case ?
C_sharp : I safely search a list for an object like this : If there are no objects that match my criteria then someResult is going to be null.But if I only have the index of the object I want , things are not so nice . I seem to have to so something like this : I admit that is not terrible to have to write . But it see...
Is there a concise built-in way to get a list item by index that is not going to throw an exception ?
C_sharp : I have a custom class that I use to build table strings . I would like to rewrite the code so that I can chain the operators . Something like : So it seems like I would have each of these methods ( functions ) return the object itself so that I can then call another method ( function ) on the resulting object...
How do I declare a class in C # so that I can chain methods ?
C_sharp : So I have a dotNet CoreCLR application for hololens and it 's my understanding that standard sockets are n't supported in CoreCLR and the recommended avenue is to use StreamSocket.It 's also my understanding that CodedInputStream and StreamSocket are n't compatible.So I 've been manually trying to decode the ...
Manually decoding the Size presend on a CodedInputStream
C_sharp : I have a MyProject project where I have IMyService interface and MyService class that implements IMyService . In Startup.cs class I dependency injection them : Because MyService has many dependencies ( makes many REST calls to 3rd party etc . ) I would like to create a stub version of it for development envir...
How to implement dependency injection in Startup.cs when dependencies are circular ?
C_sharp : ContextI have two classes : LiteralModel is a wrapper around a string Value property . Expression has a string Name and a LiteralModel called Literal.All are public properties with public getters and setters , and so I would expect both of them to serialize and deserialize easily , even with the null guards ,...
Why does the Newtonsoft deserializer not deserialize a smart getter ?
C_sharp : I have two unit tests that use TypeMock Isolator to isolate and fake a method from asp.net 's SqlMembershipProvider.In test 1 I have : In test 2 I have : When I run each test by itself they both pass successfully . When I run both tests , test number 1 runs first and passes , then test number 2 runs and fails...
TypeMock Isolator : WillThrow ( ) bleeds across unit test boundaries ?
C_sharp : I discovered a strange behavior when using property indexer ( C # ) .Consider the following program : Why do I get all results back when using the default indexer ( the x2 variable ) ? It seems that the int parameter ( 0 ) is automatically converted to the enum type ( Type1 ) . This is not what I was expectin...
Property indexer with default 0 ( zero ) value
C_sharp : I have an employees list in my application . Every employee has name and surname , so I have a list of elements like : I want my customers to have a feature to search employees by names with a fuzzy-searching algorithm . For example , if user enters `` Yuma Turmon '' , the closest element - `` Uma Turman '' w...
Implementing Levenstein distance for reversed string combination ?
C_sharp : is there any functional difference between : and if so , is there a more compelling reason to use one over the other ? <code> if ( photos.Any ( it = > it.Archived ) ) if ( photos.Where ( it = > it.Archived ) .Any ( ) )
are these two linq expressions functionally equivalent ?
C_sharp : I 'm working on optimization techniques performed by the .NET Native compiler.I 've created a sample loop : And I 've compiled it with Native . Then I disassembled the result .dll file with machine code inside in IDA . As the result , I have : ( I 've removed a few unnecessary lines , so do n't worry that add...
Why does .NET Native compile loop in reverse order ?
C_sharp : Basically , I want to write a wrapper for all ICollection < > types . Lets call it DelayedAddCollection . It should take any ICollection as its .Furthermore , I need access to that ICollection type 's generic type as the Add method needs to restrict its parameter to that type.The syntax I would imagine would ...
How do I create a generic class that takes as its generic type a generic class ?
C_sharp : I 'm working on Project Euler number 5 . I 've not Googled , as that will typically lead to a SO with the answer . So , this is what I 've got : In my mind , this makes sense . Yet VS2012 is giving me a StackOverFlowException suggesting I make sure I 'm not in an infinite loop or using recursion . My question...
How to break out of this loop
C_sharp : I 'm trying to use a .NET Regex to validate the input format of a string . The string can be of the formatSo 0AAA , 107ZF , 503GH , 0AAAA are all valid . The string with which I construct my Regex is as follows : Yet this does not validate strings in which the second term is one of 03 , 07 or AA . Whilst debu...
Simple Regular Expression ( Regex ) issue ( .net )
C_sharp : I have a method A ( ) that processes some queries . This method , from opening bracket to just before its return statement , times at +/-70ms . A good 50 % of which comes from opening the connection , about 20 % comes from the actual queries , 5-10 % is used by some memory access , the rest is ( probably ) us...
Overhead in returning from a method
C_sharp : I have two lists like these:2 list also have same size . I want some operations in listQ relation to listVal : if listVal 's any indexes have same values , I want to take average listQ 's values in same indexes . For example : So , I want listQ 's same indexes be same.Now , each these indexes must have 23.45 ...
List operations related to another list 's conditions
C_sharp : I am trying to set up a navigation between views using a MVVM pattern . My application contains a MainWindow and two views with a button each . When I click on the button in the View1 I want to set up the View2 on the MainWindow.I have found several tutorials witch explain how to navigate from a view to anoth...
WPF view who leads to another using MVVM
C_sharp : this is a small code which shows virtual methods.This code is printing the below output : I can not understand why a.F ( ) will print B.F ? I thought it will print D.F because Class B overrides the F ( ) of Class A , then this method is being hidden in Class C using the `` new '' keyword , then it 's again be...
Need to understand the below code for C # virtual methods
C_sharp : In C # I could do this : But can I do something like that in C++ ? I tried : But it does n't compile . <code> char [ ] a = new char [ ] { ' a ' , ' a ' , ' a ' } ; char *a = new char [ ] { ' a ' , ' a ' , ' a ' } ;
Array initialization when using new
C_sharp : I have a class called playingcards it inherits from a cards class . I instantiated it as an object called chuckcards . One of the data members is CARD ID . I 'm trying to assign a int to the value . it is declared public int the class.Here 's how its instantiated.playingcards [ ] chuckcards = new playingcards...
giving a class object a value c #
C_sharp : How can I quickly create a string list with numbered strings ? Right now I 'm using : This works , however I wonder if there 's a quicker way to initialize such a string list , maybe in one or two lines ? <code> var str = new List < string > ( ) ; for ( int i = 1 ; i < = 10 ; i++ ) { str.Add ( `` This is stri...
Quick way to initialize list of numbered strings ?
C_sharp : I 've noticed this type of behavior before , and it occurred to me to ask a question this time : I have a simple `` proof of concept '' program that spawns a few threads , waits for them to do some work , then exits . But Main is n't returning unless I call server.Close ( ) ( which closes the socket and ends ...
Why is n't Main returning ?
C_sharp : If I want to periodically check if there is a cancellation request , I would use the following code below constantly inside my DoWork event handler : Is there a clean way for checking a cancellation request in BackgroundWorker in C # without re-typing the same code over and over again ? Please refer to the fo...
Is there a clean way for checking a cancellation request in BackgroundWorker without re-typing the same code over and over again ?
C_sharp : I expect the following code to deadlock when Clear tries to lock on the same object that Build has already locked : Output : ClearBuildEdit 1Thank you all for your answers.If I add a call to Build inside the lock of Clear ( keeping the rest of the code the same ) : A deadlock does occur ( or at least that 's ...
Why does n't this code deadlock ?
C_sharp : I wrote a program that compiles my .cs files using csc.exe : The compile instruction runs but produces no results , just a quick flash of a black console screen . Basically what seems to be happening , is when all the strings are parsed in the commandline as arguments for the process , the .cs project source ...
Expected behaviour with white space in the command line
C_sharp : I have two snippets , one in Java and one in c # .the Java snippet returns 7101.674and in c # produces a result of 7103.674.why am I off by 2 and what is correct ? <code> float a = 1234e-3f ; float b = 1.23f ; float ca = 1.234e3f ; float d = 43.21f ; long e = 1234L ; int f = 0xa ; int g = 014 ; char h = ' Z '...
why does java and c # differ in simple Addition
C_sharp : Because I am using a `` using '' here , If there is an exception any where in the TRY will the FtpWebRequest , FtpWebRespons and responseStream automatically be closed ? <code> Try Dim request As FtpWebRequest = CType ( WebRequest.Create ( `` '' ) , FtpWebRequest ) request.Method = WebRequestMethods.Ftp.ListD...
if there is an exception in the `` using '' will it be automatically closed
C_sharp : Why input length on regex does not affect performance and how is that possible ? The generated string is like this : 128 random characters . then two numbers inside parenthesis . and this is repeated many times.The regex gets all the numbers inside parenthesis . here is the pattern.So the matches would be lik...
Why regex does not care about string length
C_sharp : I 've got a Linq To Sql query ( or with brackets ) here that works on my local SQL2008 , in about 00:00:00s - 00:00:01s , but on the remote server , it takes around 00:02:10s . There 's about 56k items in dbo.Movies , dbo.Boxarts , and 300k in dbo.OmdbEntriesThe inner query first takes all the related items i...
DbContext times out on remote server only
C_sharp : If I do the following : This works and testdecimal ends up being 12222.Should n't this reasonably/logically fail parsing ? I was surprised to see that it worked and was curious as to what is the logic behind it that allows this . <code> string teststring = `` 12,2,2,2 '' ; decimal testdecimal ; decimal.TryPar...
Why does decimal.TryParse successfully parse something like 12,2,2,2
C_sharp : When I place an open brace in Visual Studio 2017 ( C # ) the cursor automatically goes to the next line to the left of the end brace . Like this ( period as cursor ) : I 'd like the cursor to automatically be on its own line like this ( period as cursor ) : Does anybody know how to make the cursor automatical...
How to automatically place cursor between braces on its own line using Visual Studio 2017
C_sharp : Today I was thinking it would be neat to make anonymous object which is type of some interface , and I have seen on SO that I am not only one.Before I started checking out what happens I wrote some code like the one below.To my amusement it compiled , I am using .net framework 4 and I know there is no way to ...
Assign to interface array initializator compiles but why ?
C_sharp : I have a person table filled with Person information . I would like to get a list of the personer inside the table and check if they have renewed thier password in last 24 hours , and then return a person name and a boolean property whether they have updated the password or not . This is my Person table : Per...
Boolean inside of Select ( )
C_sharp : I 'm wondering if I should change the software architecture of one of my projects.I 'm developing software for a project where two sides ( in fact a host and a device ) use shared code . That helps because shared data , e.g . enums can be stored in one central place.I 'm working with what we call a `` channel...
Is it good practice to blank out inherited functionality that will not be used ?
C_sharp : I want to parse plain text comments and look for certain tags within them . The types of tags I 'm looking for look like : Where `` name '' is a [ a-z ] string ( from a fixed list ) and `` 1234 '' represents a [ 0-9 ] + number . These tags can occur within a string zero or more times and be surrounded by arbi...
Extracing specific tags from arbitrary plain text
C_sharp : I would like to know , in .NET , if the ( managed ) Microsoft UI Automation framework provides some way to instantiate an AutomationElement type given the AutomationId value of a window , suppressing this way the need to search the window by a window handle or other kind of identifiers.A pseudo example writte...
Can be instantiated the type AutomationElement given an AutomationId value ?
C_sharp : I have a class which is basically a message handler , it accepts requests , finds a processor for that message type , creates an appropriate response and returns it . To this end , I have created a delegate as follows public delegate Rs ProcessRequest < Rq , Rs > ( Rq request ) ; and then inside my class , cr...
Dynamically executing delegates
C_sharp : I am learning about implementing interfaces and generics , I made this code , but VStudio says that I did not implement System.Collections.Enumerable.GetEnumerator ( ) .Did I not do this below , generically ? It wants two implementations ? <code> namespace Generic_cars { class VehicleLot : IEnumerable < Vehic...
IEnumerable , requires two implementations ?
C_sharp : I have this code to open multiple urls from a richtextbox , it works fine , but the problem is that it opens all sites in separate browsers . Any ideas how I can open the pages like tabs in the same browser ? <code> private void button1_Click ( object sender , EventArgs e ) { for ( int i = 0 ; i < richTextBox...
how to open multiple urls from richtextbox
C_sharp : While reading this answer from another question I was 100 % sure that the following code would lock up the UI and not cause any movement.I and several others in the comments said it would not work but the OP insisted that it did and we should try . I ended up making a new Winforms project , adding a button , ...
Why does my form NOT lock up ?
C_sharp : I do n't know if I 'm missing something ... anyway : You can see , for example , that the object with the property 'HomeTeam ' = ' Forest Green Rovers ' has the state = 'Unchanged ' . Anyway all entities are 'unchanged ' in my case . So , if I 'm correct , the saveChanges should n't try to insert those in my ...
SaveChanges ( ) is saving Unchanged records
C_sharp : This was a interview question - How will you efficiently trim the duplicate characters in string with single character . Example : suppose this is the input string `` reeeturrrnneedd '' The output should be : `` returned '' I explained it by using splitting the string and loop through the char array , but int...
Trimming duplicate characters with single character in string
C_sharp : I 've been thinking recently about the Liskov Substitution Principle and how it relates to my current task . I have a main form which contains a menu ; into this main form I will dock a specific form as a MDI child . This specific form may or may not contain a menu . If it does , I want to merge it with the m...
Does one child implementing an interface , but another not , violate the Liskov Substitution Principle ?
C_sharp : I am working on EF . I am trying to insert into a table , the insert function is in a thread . And this is my save data function The above code runs for some time , but after that I encountered an error at u.SaveChanges ( ) ; System.Data.Entity.Core.EntityException : 'An error occurred while closing the provi...
EF inserting values in table failed after some time
C_sharp : I have an interesting thought-problem right now , so maybe someone of you could help.Basically what I have is an array of bytes and need to know the order of each individual item in that array - by value . Oh man , i will just show you a small example , i think that will help better : I want to get this as a ...
Get the order of bytes by value
C_sharp : I ’ m having an issue ( probably due to my lack of familiarity of C # generics ) in getting the unclosed type of a generic . I have several methods that look rather similar to the following except for the explicit validator interface in use . The method GetRecursiveBaseTypesAndInterfaces does as it says and g...
Retrieving the unclosed type of a generic type closing a generic type
C_sharp : Possible Duplicate : Foreach can throw an InvalidCastException ? Consider the following block of codeNotice the cast from Base to DerivedLeft in foreach statement . This compiles fine ( Visual Studio 2010 ) , without any error or even warning.Obviously , on the second loop-iteration we will get an InvalidCast...
Why does compiler let this slip ?
C_sharp : everyone , I want one application that could control window open and close multi-time . For example , press 1 , open a window ; press 2 , close the window.And there is my code I found , which only could do this once.Could somebody be nice to help me correct it ? Thanks a lot . <code> public static void Main (...
How I re-open WPF window in the same pragrom/application ?
C_sharp : I want to transfer BusinessObjects from one PC to another . If I think about a number of around 40 different object types to transfer the use of many contracts for the different objects would seem to be quite some overload for always the same task : `` Send Object A to Computer B and save object to DB '' ( ob...
How to use a variable as type
C_sharp : I am reading through documents , and splitting words to get each word in the dictionary , but how could I exclude some words ( like `` the/a/an '' ) . This is my function : Also , in this scenario , where is the right place to add .ToLower ( ) call to make all the words from file in lowercase ? I was thinking...
Excluding words from dictionary
C_sharp : I 'm trying to convert this simple class to IL code : In fact I used ILDasm to know the IL instructions before trying to use Emit to create the class dynamically . The result it shows is : From that , I tried using Emit like this : Now try using it : That means the IL code would be wrong at some point . But c...
Converting simple class to IL failed due to some invalid IL code ?
C_sharp : I would appreciate any help from the PLYNQ experts out there ! I will take time reviewing answers , I have a more established profile on math.SE.I have an object of type ParallelQuery < List < string > > , which has 44 lists which I would like to process in parallel ( five at a time , say ) . My process has a...
Possible reasons why ParallelQuery.Aggregate does not run in parallel
C_sharp : I have added a web ref to my .net project which contains the methods for a 3rd party service.When I try to call one of the methods its expecting an OrderIdentifier object to be passed but its giving me the error : InvalidOperationException : < > f__AnonymousType0 ` 3 [ System.DateTime , ETS_OpenAccessNew.ETS....
Web Service method - can not be serialized because it does not have a parameterless constructor
C_sharp : I am working on the first lab of headfirst C # . I ran into a problem in my program that the dogs go at the same speed . I cant figure out why they do so , because in my eyes every object instance get a random 1 to 5 pixels added to its X location . The randomness of this should make enough of a difference.So...
Dogs go at same speed
C_sharp : Why does this snippet of code produces 60ddd , and this one produces ddd302010 ? Seems like it 's very simple , but I ca n't get my head around it.Please , show me direction in which I can go in order to find a detailed answer.Thanks ! <code> string str = 30 + 20 + 10 + `` ddd '' ; Console.WriteLine ( str ) ;...
How does c # string evaluates its own value ?
C_sharp : Is there a way to use value ending with space as XmlPoke value ? When I execute task , value is replaced but without space at the end.Reproduction : test.targets : test.xml : When I run : I get output.xml without space : Is there a way to force XmlPoke to set correct value ( with space at the end ) ? <code> <...
XmlPoke task trims value
C_sharp : I am wanting to trim any white space off a collection of strings . I used the following code but it does n't seem to work . Could anyone explain why ? <code> result.ForEach ( f = > f = f.Trim ( ) ) ;
Do n't understand why the ForEach command is n't working
C_sharp : This question is somewhat an illustration to a related post , I believe the example below describes the essence of the problem.Is n't it bad that the second call to GetData raises exception only because GetData received a parameter cast to dynamic ? The method itself is fine with such argument : it treats it ...
Bad interoperability between static and dynamic C #
C_sharp : I am writing an IComparer < T > implementation by deriving from the Comparer < T > class , as recommended by MSDN . For example : However , under this approach , the MyComparer class inherits the Default and Create static members from the Comparer < T > class . This is undesirable , since the implementation o...
Should derived classes hide the Default and Create static members inherited from Comparer < T > ?
C_sharp : Is there a difference between these two implementations ? 1 :2 : The first one seems to be more correct than the second in regards to memory leaks . But is it really correct ? <code> public class SMSManager : ManagerBase { private EventHandler < SheetButtonClickEventArgs > _buttonClickevent ; public SMSManage...
Difference between two dispose implementations ?