text
stringlengths
46
37.3k
title
stringlengths
12
162
C_sharp : Following code to do a simple property assignment person.Name = `` Joe Bloggs '' by dynamically creating a method using an Expression Tree fails with a NullReferenceException - it 's like the person parameter I create is n't being passed in.Any ideas ? UpdateThanks for the great answers , I saw @ decPL 's fir...
Dynamic Methods with Expression Trees : Simple property assignment fails
C_sharp : I 've got controller code like this all over my ASP.NET MVC 3 site : Basically , i 'm referring to the code in the threading block . All things need to happen , but the user does n't need to wait for them ( good case for a background thread , right ? ) .Just to be clear , i use caching ( regular ASP.NET data ...
Can this MVC code be refactored using a design pattern ?
C_sharp : In our organization we have the need to let employees filter data in our web application by supplying WHERE clauses . It 's worked great for a long time , but we occasionally run into users providing queries that require full table scans on large tables or inefficient joins , etc.Some clown might write someth...
Ensure `` Reasonable '' queries only
C_sharp : All of the above are possible except for the constant field of struct type.I can see why the non-string reference types would default to the only literal expression they can represent - null - but if I 'm not mistaken the default value of a struct is an instance of the struct with all its fields set to their ...
Why ca n't a constant field be of non-built-in struct type in C # ?
C_sharp : The point of M-V-VM as we all know is about speraration of concerns . In patterns like MVVM , MVC or MVP , the main purpose is to decouple the View from the Data thereby building more flexible components . I 'll demonstrate first a very common scenario found in many WPF apps , and then I 'll make my point : S...
M-V-VM , is n't the Model leaking into the View ?
C_sharp : I 'm playing around with a simple console app that creates one thread and I do some inter thread communication between the main and the worker thread.I 'm posting objects from the main thread to a concurrent queue and the worker thread is dequeueing that and does some processing.What strikes me as odd , is th...
Two threads one core
C_sharp : Is there a c # library that can help to write and indent Javascript code.It 's because I 'm writing some c # code that generated some Javascript code . Something like this : And I find that generated a lot of ugly code.So , I thought that maybe a existing library can help me doing that ? <code> js += `` < scr...
Library to write javascript code
C_sharp : I want to have an abstract UserControl , BaseControl , that implements an interface IBaseControl.However , setting the class to abstract breaks VisualStudio designer ( This is a known issue with Visual Studio ( e.g. , see this StackOverflow posting for more info ) , and as far as I know , there 's no change e...
VisualStudio 2010 Designer throws on implemented virtual method
C_sharp : I 'd like to convert string containing recursive array of strings to an array of depth one.Example : Seems quite simple . But , I come from functional background and I 'm not that familiar with .NET Framework standard libraries , so every time ( I started from scratch like 3 times ) I end up just plain ugly c...
parsing of a string containing an array
C_sharp : I have a .wav file and I am plotting waveform using ZedGraph . I am calculating the energies of .wav file of each second and if energy is less then 4 I want to draw the sample in different color . I have created two PointPairLlist and LineItem to do this but there is a problem while merging these two list . H...
Merging multiple pointpairlist
C_sharp : I have spent hours on a debugging problem only to have a more experienced guy look at the IL ( something like 00400089 mov dword ptr [ ebp-8 ] , edx ) and point out the problem . Honestly , this looks like Hebrew to me - I have no idea what the heck it 's saying.Where can I learn more about this stuff and imp...
How to become an MSIL pro ?
C_sharp : I have a string [ ] which contains code . Each line contains some leading spaces . I need to 'unindent ' the code as much as possible without changing the existing formatting.For instance the contents of my string [ ] might beI 'd like to find a reasonably elegant and efficient method ( LINQ ? ) to transform ...
Efficient way to unindent lines of code stored in a string
C_sharp : I have ; How much space does this need ? Does linq build up a list of the above Where ( ) condition , or is Max ( ) just iterating through the IEnumerable keeping track of what is the current Max ( ) ? And where can I find more info about this , besides asking on SO f <code> var maxVal = l.TakeWhile ( x= > x ...
space complexity of a simple linq ( to objects ) query
C_sharp : For those who are interested in how I do the benchmark , look here , I simple replace / add a couple of methods near the build in `` Loop 1K '' method.Sorry , I forgot to say my testing environment . .Net 4.5 x64 ( do n't pick 32bit preferred ) . in x86 both methods take 5x as much as time.Loop2 takes 3x as m...
How to explain the difference of performance in these 2 simple loops ?
C_sharp : How to enable Password Char in TextBox except last N character ? I already tried this method But it is so hard to manipulate , I will pass original card value in every event like Keypress , TextChange and etc..Is there I way that is more simple and easy to managed ? <code> cardnumber.Select ( ( c , i ) = > i ...
Enable Password Char in TextBox except last N character / Limit Masked Char
C_sharp : I think there is quite a confusion over the usage of `` On '' as prefix of a C # method.In MSDN article `` Handling and Raising Event '' https : //msdn.microsoft.com/en-us/library/edzehd2t ( v=vs.110 ) .aspx it says , Typically , to raise an event , you add a method that is marked as protected and virtual ( i...
What does prefix `` On '' implement in event cases in C # coding ?
C_sharp : I have an IHttpHandler which I believe can benefit from re-use , because it is expensive to set up , and is thread-safe . But a new handler is being created for each request . My handler is not being re-used.Following is my simple test case , without the expensive setup . This simple case demonstrates my prob...
IHttpHandler IsReusable , but is not getting re-used
C_sharp : This is a very strange problem that I have spent the day trying to track down . I am not sure if this is a bug , but it would be great to get some perspective and thoughts on why this is happening.I am using xUnit ( 2.0 ) to run my unit tests . The beauty of xUnit is that it automatically runs tests in parall...
Is ConstructorInfo.GetParameters Thread-Safe ?
C_sharp : I found a method to shuffle an array on the internet.However , I am a little concerned about the correctness of this method . If OrderBy executes x = > rand.Next ( ) many times for the same item , the results may conflict and result in weird things ( possibly exceptions ) .I tried it and everything is fine , ...
In LINQ , does orderby ( ) execute the comparing function only once or execute it whenever needed ?
C_sharp : back in school , we wrote a compiler where curly braces had the default behavior of executing all expressions , and returning the last value ... so you could write something like : Is there something equivalent in C # ? For instance , if I want to write a lambda function that has a side effect.The point less ...
C # scoping operator
C_sharp : I have this method : It 's not working correctly as it seems like I need the value of { 0 } needs to be a 0 or a 1 . Is there a simple way that I can take value and change it to be a 0 or a 1 ? <code> public void UpdatePhrase ( PHRASE phraseColumn , bool value , string phraseId ) { sql = string.Format ( `` UP...
How can I change a bool to a 0 or a 1 , can I cast it ?
C_sharp : Let 's say I have the following method : A colleague of mine is convinced that this a bad method signature . He would like me to use a Request object , which would transform the method signature into this : I really do n't see the point of doing that . The only benefit I see is that it will be easier to add p...
Request object , what are the pros and cons ?
C_sharp : For some classes , ideally , I 'd like to create special named instances , similar to `` null . '' As far as I know , that 's not possible , so instead , I create static instances of the class , with a static constructor , similar to this : As you can see , Person.Waldo is a special instance of the Person cla...
C # How to create special instances of a class ?
C_sharp : I have the following class structure : Is it possible to pivot the List < Employee > with Linq so i have result like this in my DataGridView : It 's tricky because it 's two nested lists and i only found examples with single list which are pretty straightforward.Is it possible to Pivot data using LINQ ? I got...
Pivot data in two nested List < T > with Linq
C_sharp : F # has a convenient feature `` with '' , example : F # created keyword `` with '' as the record types are by default immutable.Now , is it possible to define a similar extension in C # ? seems it 's a bit tricky , as in C # i 'm not sure how to convert a string to a delegate or expression ? <code> type Produ...
C # : how to define an extension method as `` with '' in F # ?
C_sharp : I have a basic buddylist type application which is a pub/sub deal in WCF . My problem is one or two of the calls are long running and this blocks up the entire server application ( gui updates etc ) .Here 's my code : So far I have an idea on how to go about it but is there a simpler way ? Idea 1 : Have GetAB...
C # WCF NetTCPBinding Blocking Application
C_sharp : I need to generate all possible numbers ( integers ) from 0 to 999999 ( without repetition ) while respecting a series of constraints.To better understand the requirements , imagine each number being formed by a 2 digit prefix and a suffix of 4 digits . Like 000000 being read as 00-0000 and 999999 as 99-9999 ...
How to generate a sequence of numbers while respecting some constraints ?
C_sharp : I have a WCF service where I use a custom UserNamePasswordValidator to validate user . When this is done the IAuthorizationPolicy.Evaluate is triggered and this is where I set the principal to a custom user context like this : The problem is that I need 2 things to get the proper usercontext and this is usern...
Login with IAuthorizationPolicy and UserNamePasswordValidator with header data ?
C_sharp : I 've made such experiment - made 10 million random numbers from C and C # . And then counted how much times each bit from 15 bits in random integer is set . ( I chose 15 bits because C supports random integer only up to 0x7fff ) .What i 've got is this : I have two questions : Why there are 3 most probable b...
Most probable bits in random integer
C_sharp : What could possibly be the reasons to use - instead of , or , even simpler - for comparing two strings in .NET with C # ? I 've been assigned on a project with a large code-base that has abandon use of the first one for simple equality comparison . I could n't ( not yet ) find any reason why those senior guys...
Efficient ( ? ) string comparison
C_sharp : I 'm using WinForms . In my forms I have an open and a next button . My application opens .tif images into a picturebox . All the .tif images I work with have multiple pages . The next button is for going to the next page in the tif image . These .tif images I work with are very large.Example : Dimensions : 2...
Boost the performance when advancing to the next page using .tif images
C_sharp : I have now a scenario that needs to add and remove items in multi-threading conditionI 'm doing andBut I have now a very big problem with race condition . The lock time is increasing and incrasing.I wished I could use ConcurrentBag but it does n't has Contains Method , so I ca n't remove the specific item I w...
What 's the best way of adding/removing a specific item from List < T > in multi-threading scenario
C_sharp : My project compiles in VS 2013 but does not compile in VS 2015 . Below code reproduces the compile problem . The Validator classes are actually in a 3rd party assembly so I can not change the implementation . The require class is a local class but I do n't want to change the implementation because I will have...
Visual Studio 2015 does not compile when generic type matches overloaded method that takes that type
C_sharp : Consider : Note the third Console.WriteLine - I 'm expecting it to print the type to which the array is being cast ( Int32 [ ] ) , but instead it prints the original type ( Foo [ ] ) ! And ReferenceEquals confirms that indeed , the first Cast < int > call is effectively a no-op.So I peeked into the source of ...
Type system oddity : Enumerable.Cast < int > ( )
C_sharp : I have a class called Global that derives from HttpApplication.Oddly , I see a lot of methods inside Global that look like : The code is definitely executing inside this method , so the method is being called from somewhere , but where ? The methods are n't marked overload ? Secondly , I derived a class from ...
Confused over global.asax ?
C_sharp : I am trying to understand the contents of a .csproj file after I converted from PCL to a .NET shared . Here is an example and some questions : Can someone explain to me why only certain folders appear above even though my project has many more foldersCan someone explain what all these Remove lines do / mean ?...
C # project file - Why does n't it represent what 's in my project ?
C_sharp : I have started looking at using Reactive Extensions with EventStore . As a proof of concept , I 'd like to see if I can get Rx to consume an event stream and output the count of events grouped by type for a window of one second . So , say that I am consuming a stream with the name `` orders '' , I 'd like to ...
Rx : Count of Grouped Events in Moving Window
C_sharp : I have a table payments that has a null-able integer column named payMonth . I have the following class and list : The problem comes here . When data is displayed in the dgv , the DataGridViewComboBoxColumn cmbMonth shows the number values ( 1,2,3 , ... ) not the month name ( 'Jan ' , 'Feb ' , 'Mar ' , ... ) ...
C # binding datagridviewcomboboxcolumn to list display , formatting , preferred Size error
C_sharp : Consider the following example : How could parallel read access to the Contents List be achieved without copying the whole List ? In C # there are concurrent Collections , but there is no thread safe List . In Java there is something like the CopyOnWriteArrayList . <code> class Example { private readonly List...
C # parallel read access to List without copying
C_sharp : I have ( legacy ) VB6 code that I want to consume from C # code . This is somewhat similar to this question , but it refers to passing an array from VB6 consuming a C # dll . My problem is the opposite.In VB , there is an interface in one dll , and an implementation in another.Interface : Implementation ( fra...
Consuming VB6 string array in C #
C_sharp : I 'm developing a WPF application whose Window size and component locations must be dynamically calculated upon initialization because they are based on the main UserControl size I use and some other minor size settings . So , for the moment , I 've placed those constant values in my Window code as follows : ...
Elegant Solution for Readonly Values
C_sharp : I 'm reviewing a piece of code I wrote not too long ago , and I just hate the way I handled the sorting - I 'm wondering if anyone might be able to show me a better way.I have a class , Holding , which contains some information . I have another class , HoldingsList , which contains a List < Holding > member ....
Looking for a better way to sort my List < T >
C_sharp : I have a simple method which converts an array from one type to another . I wanted to find out which method is the fastest . But so far I get differing results from which I can not conclude which method is really faster by which margin . Since the conversion is only about allocating memory , reading the array...
Why are performance measurements differing ?
C_sharp : Followed Functional Reactive Programming tutorial , where stream of events ( Observable ) is directly created from System.Timers.Timer.Elapsed event.Have class defined in C # Referenced corresponding .dll into F # project and trying to create Observable from Notifier.OnMessage event Getting error message The ...
Consume C # event from F #
C_sharp : I do understand that there 's no multiple inheritence in C # . However , I 've run into a situation in which I really wish it existed . I am creating a custom class that requires me to inherit from CLR types and override a few methods . Unfortunately , I am creating several of these which are very similar . I...
Multiple Inheritance in C # : What is the purist way of achieving what I am trying to do ?
C_sharp : I have Tiles which represent the tiles in a game 's 2-dimensional world . The tiles can have walls on any number of their 4 sides . I have something like this at the moment : Somewhere else I also have 16 images , one for each possible tile wall configuration . Something like this : I want to write a What I '...
Nice way to do this in modern OO C-like language ?
C_sharp : When I decided to make my own implementation of Java ByteBuffer in C # I thought it would be faster than MemoryStream + BinaryWriter/BinaryReader . I looked at their source through ILSpy and there was a lot of checks and helper methods calls , while in my implementation I work directly with an underlying arra...
Why does c # built-in IO classes is faster than self-made ones ?
C_sharp : A bit of a basic question , but one that seems to stump me , nonetheless.Given a `` nested generic '' : Is this stating that IEnumerable can have generic types that are themselves KeyValuePair 's ? Thanks , Scott <code> IEnumerable < KeyValuePair < TKey , TValue > >
What do nested generics in C # mean ?
C_sharp : I have written an F # module that has a list inside : Now from a C # class I 'm trying to access the previously defined list , but I do n't know how converting it : I 'd need something like : How can I achieve that ? <code> module MyModuletype X = { valuex : float32 } let l = [ for i in 1 .. 10 - > { valuex =...
Accessing an F # list from inside C # code
C_sharp : I 'm trying to make my first system application for Android related to geolocation and local notifications.I imagine it like this ... There is basic activity MainActivity . After start it launches a service TestService which in case of change of coordinates sends them on the server , and in reply receives som...
Geolocation , service and local notifications
C_sharp : I have a list of Foo : And I want to convert it to a list Bar : The data in Foo looks like this : And I want it to look like this : I 'm doing this so it will be easier to display in a Razor rendered Html unordered list . Also , if there is an easy way to do this without conversion , please let me know.Ultima...
Convert List < T > into another List < T > that contains another List < T >
C_sharp : In probably the best error message I 've gotten in awhile , I 'm curious as to what went wrong.The original code I 'm using Unity3d and C # ; LeftArm is a bool type and according to documentation Elbow.transform.localRotation.eulerAngles.y returns a float value.This code gives me the error : There exists both...
There exists both implicit conversions from 'float ' and 'float ' and from 'float ' to 'float '
C_sharp : I have the following code : Now somewhere else in my code , I make about 2500 calls in a loop to Character.LevelPosition.This means that per update-cycle , 5000 'new ' Vector2s are being made , and on my laptop , it really drops the framerate.I have temporarily fixed it by creatingbefore I initiate the loop ,...
'new ' keyword in getter > performance hit ?
C_sharp : I am trying to remove duplicates item from bottom of generic list . I have class defined as belowAnd I have defined another class which implements IEqualityComparer to remove the duplicates from ListHowever , I am trying to remove the old items and keep the latest . For example if I have list of identifier de...
Removing Duplicates from bottom of Generic List
C_sharp : I 'm reading this introduction to Polyphonic C # and the first page contains this example : Example : A Simple BufferHere is the simplest interesting example of a Polyphonic C # class : I do n't get it at all.What does the & between methods get ( ) and put ( ) signify ? <code> public class Buffer { public Str...
Polyphonic C # methods separated by ampersand ?
C_sharp : I have a two generic abstract types : Entity and Association.Let 's say Entity looks like this : and Association looks like this : How do I constrain Association so they can be of any Entity ? I can accomplish it by the following : This gets very tedious as more types derive from Association , because I have ...
How to declare a generic constraint that is a generic type
C_sharp : i want to render nice radial tree layout and a bit stumbled with curved edges . The problem is that with different angles between source and target points the edges are drawn differently . Provided pics are from the single graph so you can see how they 're differ for different edge directions . I think the po...
Radial tree graph layout : fix beizer curves
C_sharp : I have a client that sends an xml feed which I parse using the following code . This code works.After getting all my `` reviews '' I cast the IEnumerable as a List and return it out . Originally , I was having a good and easy time parsing their XML which used to look like this : They have , however , changed ...
How to ignore a specific with a LINQ where clause ?
C_sharp : Consider the following snippets : compared toCode including Foo ( ) successfully compiles in .Net 4.6.1 , while code including Bar ( ) results in Use of unassigned local variable 'comboBox ' . Without getting into a debate over the reasons behind using == false instead of the negation operator , can someone e...
Inline variable declaration does n't compile when using '== false ' instead of negation operator
C_sharp : I 've seen some examples where they transformed a call likeintoBeside tricking the intellisense into displaying the name of your class instead of the interface name when calling the function , because of inferred type usage in C # 4 , are there any other advantage to using the second approach ? To answer Jon ...
What are the advantage of using a generics-where-clause call over a non-generic call ?
C_sharp : What I have learned so far is that we can not create an instance of an interface . IFood food = new IFood ( ) ; //this gives compile errorIFood food = new Apple ( ) ; //this will workUpto here everything were okay . But when I work with Microsoft.Office.Interop.Excel I have seen something like belowApplicatio...
How is it possible to initialize an interface ?
C_sharp : Is it possible to dynamically compose a class from the methods contained in other Classes ? For instance . Class A , B and C have public methods named such that they can be identified easily . They need to be extracted and added to Class D. Class D , which then contains all of the implementation logic can be ...
Dynamically Compose a Class in C #
C_sharp : I have this code , and i want to store values of parameters left , top in static dictionary . and after storing this values i want to access them in Jquery.Thanks For your Help.my code <code> using Microsoft.AspNet.SignalR ; using Microsoft.AspNet.SignalR.Hubs ; using System ; using System.Collections.Generic...
C # Store values in static dictionary
C_sharp : Let 's say we have a collection of documents like this one : How do you extract only the documents where no item in the array $ .carts have $ .carts.closed set to true and $ .carts.updatedon greater than $ .updatedon minus 3 days ? I know how to do find all the documents where no item in the array satisfy the...
Find if an element in array has value equal to parent element value
C_sharp : I was just implementing the Dispose pattern , and when I just typed the GC.SuppressFinalize ( this ) line , I was wondering if there is ever a use case for using something other than this as the parameter to the method.This is the typical pattern : Does it ever make sense to call GC.SuppressFinalize ( ) with ...
Is there a use case for not using `` this '' when calling GC.SuppressFinalize ( this ) ?
C_sharp : Using Linq on collections , which one is best for finding that collection is not empty ? and <code> HasChild = Childs.GetEnumerator ( ) .MoveNext ( ) ? true : false ; HasChild = Childs.Any ( ) ? true : false ;
Linq Any ( ) vs MoveNext ( )
C_sharp : I have previously asked a similar question on SO to which I got an answer . At the time , for the sake of expediency , I mechanically applied the answer but now I 'm trying to get a handle on how the mechanism for declaratively setting up a fixture is.So , I am currently looking at Mark Seemann 's Dealing Wit...
What are the principles behind AutoFixture 's declarative way of setting up a fixture ?
C_sharp : Suppose the following code : Functionally , these functions are exactly the same but the compiler treats calling these methods different . The following code compiles , but issues a CS4014 warning : It generates the warning `` because this call is not awaited , the current method continues to run before the c...
Why is CS4014 not shown for all functions that return a task ?
C_sharp : I have 3 functions where the only difference in is the values I point out with commentThe majority of the function is the same across all three . The `` DRY '' factor is haunting my sleep : ) . I was wondering ; can these could be merged easily and readably ? I have had situations like this before and I am ho...
How to refactor these functions which have one line difference
C_sharp : When i run following code in .Net Core 3.1 i get 6Resultbut when i run this code in .Net 5 i get different result . why ? Result <code> //Net Core 3.1string s = `` Hello\r\nworld ! `` ; int idx = s.IndexOf ( `` \n '' ) ; Console.WriteLine ( idx ) ; 6 //NET 5string s = `` Hello\r\nworld ! `` ; int idx = s.Inde...
string.IndexOf get different result in .Net 5
C_sharp : ASP.Net Identity is executing the queries below on every request . I have not changed any of the Identity code that was gen 'd when my MVC project was created . My Startup.Auth.cs code is below.Note that validateInterval is set to TimeSpan.FromMinutes ( 30 ) . Also note that cookie expiration is being explici...
ASP.Net Identity running multiple queries on every request
C_sharp : I have this C # DLL : And this F # app which references the DLL : No-one initiates the Instance static variable . Guess what the output of the F # app is ? After a few tests I found out that unless I use this ( e.g . to access instance field ) , I wo n't get NullReferenceExpcetion . Is that an intended behavi...
F # / .NET null instance oddity
C_sharp : I know that there are some atmoic types defined in C # , from where I ca n't find array.Opration 1 is something like a pointer reassignment . Does itguarantee to be atmoic ? How about operation 2 ? <code> var a = new bool [ ] { true , false } ; var b = new bool [ 4 ] ; a=b ; //operation 1a [ 1 ] =true ; //ope...
Is array write atomic in C # ?
C_sharp : I have hierarchy of classes like follows ( in fact I have more than 3 derived types ) : Instances of these classes are stored in List < A > collections . Sometimes collections are quite big ( thousands or even tens of thousands of objects ) .In my code I frequently need to perform some actions depending on th...
Efficient run-time type checking
C_sharp : I have a raspberry pi with system language set to `` de_DE.UTF-8 '' and mono version 3.28 installed . My programs need to convert Strings into Doubles , but I ran into a few problems : Works just fine.Throws FormatException , what is weird.Throws FormatException too ; The funny thing is if I change my system ...
Double.Parse fails in german locale
C_sharp : I have a database with two tables . Both of these tables are related and have the same key field . For example , both of them have rows of data corresponding to ISBN = 12345 , but the two tables have differing data about that ISBN . So , I 'm trying to figure out how to display data from both tables into one ...
Need some help working with databases in C #
C_sharp : I was looking at the mvc-mini-profiler designed by the Stack Overflow team on Google Code and one thing on the getting started page struck me as particularly strange : How can it be `` ok '' if profiler is null ? It seems to me that calling Step would throw a NullReferenceException . In all my years of progra...
Calling methods on a null reference in the context of a using clause is OK ?
C_sharp : I think my problem is best explained with a code snippet of my class/interface-hierarchy : Question 1 : Why does s1.Transform ( v ) resolve to ITransform < ISelection > and not to ITransform < IValue > as in the second case ? Question 2 : For Question 1 it seems to make no difference if ITransform is < D > or...
Method overload resolution and generic/contravariant interfaces in C #
C_sharp : I 'm building an application using ASP.net MVC 3 and I 'm wondering if anyone knows a great library to fill the gaps of the build-in html form field helpers ? E.g . creating a Textbox is easy : But for creating a Dropdown list I have to write : And it should be written like where DropdownTest is a SelectList....
Has anyone a great library for the missing MVC 3 html form field helpers ?
C_sharp : I am trying to write an extension method in order to refactor a linq many-to-many query I 'm writing . I am trying to retrieve a collection of Post ( s ) which have been tagged with any of the Tag ( s ) in a collection passed as a parameter to my method.Here are the relevant entities along with some of their ...
Writing an extension method to help with querying many-to-many relationships
C_sharp : If in F # I have methods like : Would they be transferred to C # , exactly the same ? If that 's the case , then would n't it compromise the naming conventions in C # , where methods are supposed to be PascalCase ? Or should I make them PascalCase in F # as well to remedy this ? <code> drawBoxdrawSpherepaintI...
How do F # types transfer over to C # ?
C_sharp : The program below produces this output : So , Foo ( baz ) calls the generic Foo < T > , but Bar ( baz ) recurses and does not call Bar < T > .I 'm on C # 5.0 and Microsoft .NET . The compiler seems to choose the generic method , instead of recursion , when the non-generic method is an override.Where can I fin...
Why is a generic method chosen when a non-generic exists ?
C_sharp : In regards to the following code : Is the SqlConnection initialized with `` using '' so it is dereferenced/destructed after the brackets ? Please correct my questioning where necessary . <code> using ( SqlConnection sqlConnection = new SqlConnection ( connectionString ) ) { code ... }
C # : Initializing a variable with `` using ''
C_sharp : I have a server side developed in c # with entity framework as a provider for SQL server . My server is managing a many to many relation between students and classes.My client side is developed in angular js with Typscript.To be synchronized with the server , each change in server is pushed to the clients wit...
Performance issue using in memory database with Typescript/javascript
C_sharp : I have faced a strange problem . Here I reproduced the problem.Until now , I thought that Linq functions get executed when they are called . But , in this method it seems after I call ToList the Linq function OrderBy executes again . Why is that so ? <code> Random r = new Random ( ) ; List < int > x = new Lis...
IEnumerable repeats function
C_sharp : I 'm trying to understand some workings of Abap-OO . In C # it is possible to restrict a type to be any type but conform at least to certain ( multiple ) interfaces through constraints in generics by doing : Is it possible to archive the same in abap-oo ? I want to pass in any object as a parameter to a metho...
Constraints on parameter to implement two interfaces
C_sharp : This has `` always '' bothered me ... Let 's say I have an interface IFiddle and another interface that does nothing more than aggregate several distinct IFiddles : ( The concrete IFiddleFrobblers and IFiddles depend on configurations and are created by a factory . ) I repeatedly stumble on the naming of such...
How should I name an `` umbrella '' type sanely ?
C_sharp : Ever since I found out about auto properties , I try to use them everywhere . Before there would always be a private member for every property I had that I would use inside the class . Now this is replaced by the auto property . I use the property inside my class in ways I normally would use a normal member f...
Is always prefixing ( auto ) properties with the this-keyword considered a good practice ?
C_sharp : Hello I am trying to make a C # program that downloads files but I am having trouble with the array.I have it split up the text for downloading and put it into a 2 level jagged array ( string [ ] [ ] ) .Now I split up the rows up text by the | char so each line will be formatted like so : { filename } | { fil...
Can only display array by iterating through a for loop
C_sharp : To get the current activity in Unity without Firebase Cloud Messaging , the following code works : However , Firebase Cloud Messaging extends the default Unity Activity . So I changed my AndroidJavaClass as such : However , I now get the following error in my logcat : I do not understand why . It says that cu...
How can I get the current activity while using Firebase Cloud Messaging in Unity ?
C_sharp : I 'm designing a fluent API and the usage is somewhat like this : So , let 's say that work is of type IUnitOfWork , but the method WithRepository ( c = > c.Users ) returns an interface called IActionFlow < IUserRepository > which is IDisposable.When I call Execute ( ) and get the final result , I lose the re...
Disposing object from same object
C_sharp : What i 'm trying to do is get Type of enum which is nested in Class having only name of that enumerator as string.example : i need get Is there any way to get this Type in runtime ? Thanks in advance : ) <code> public static class MyClassWithEnumNested { public enum NestedEnum { SomeEnum1 , SomeEnum2 , SomeEn...
Getting type of nested enum having only string ?
C_sharp : I was looking at a code sample in C # . There is ; without any statement before it . I thought it is typo . I tried to compile with ; . It compiled fine . What is the use of ; without any code statement ? I 'm using VS 2010 , C # and .Net 4.0 <code> private void CheckSmcOverride ( PatLiverSmc smc ) { ; if ( s...
a ; without statement in C #
C_sharp : I open two files into 2 seperate DGVs.. Once opened and the button `` Format '' is clicked , it matches all of the lines in the two seperate DGVs and copies it into a new DGV.The first DGV looks like this ( column labels ) : and the second DGV looks like this : The two files will match the PkgStyle and concat...
Saving DataGridView
C_sharp : I have this struct : And I 've set breakpoints as indicated by the comments above.Then I do this : I 'm observing some strange behavior when it enters if ( first == ( MyValue ) null ) : the second breakpoint is hit for some reason . Why is it trying to convert the MyValue into a string for a simple equality c...
Strange conversion operator behavior
C_sharp : So given a static type in your code you can doHow would you do the same thing given a variable of Type so you can use it during runtime ? In other words how do I implement the following method without a bunch of if statements or using Generics ( because I will not know the type I 'm passing into the method at...
C # : How to find the default value for a run-time Type ?
C_sharp : I 've created a database according to which the user profile is formed by the following two classes : I want to connect them by having both as primary key the UsrID and I get an error that UsrDetails do n't have a primary key because I 'm using the foreign key attribute . Any ideas ? <code> public class Usr {...
Error with primary key in one-to-one relationship using Entity Framework
C_sharp : I would like to know if an IQueryable object 's Expression contains a certain `` Where clause '' . For example , given as IQueryable instance , which could be something like : How can I determine if the query is filtering the customers by Name ? <code> var query = customers.Where ( c = > c.Name == `` Test '' ...
Analyzing a Linq expression
C_sharp : I want to ( am trying to ) make my code more readable . I have been using the following class aliasing.But I think something like ( note : I 'm attempting to describe FeatureHistogram in terms of Histogram here , rather than EmpiricScore < int > > ) : Seems more readable ( the dependencies can go much deeper ...
Aliasing multiple classes in C #
C_sharp : The Set Up : Loading a DataReader into a DataTable . Attempting to alter a column in the DataTable after load.The Problem : ReadOnlyException triggered when attempting to alter a column.The Conditions : When a function ( udf or system ) is applied to an aliased column inthe stored procedure , the column becom...
TSQL Functions used in stored procedure force column to readonly