text
stringlengths
46
37.3k
title
stringlengths
12
162
C_sharp : The following code : produces the following output in the textbox : From the first line of the output , it is clear that in the regional setting of my PC , date/time is formatted as date.month.year HHmm.ss.The second line of the output is confusing to me . Though I specified MM/dd/yyyy format for the variable...
Formatting DateTime to string
C_sharp : I just programmed a simple reverse loop like this : but it does n't stop at 0 as expected but goes down far to the negative values , why ? See this ideone sample : http : //ideone.com/kkixx8 ( I tested it in c # and c++ ) <code> for ( unsigned int i = 50 ; i > = 0 ; i -- ) printf ( `` i = % d\n '' , i ) ;
strange behavior of reverse loop in c # and c++
C_sharp : I have a customer that is trying to access their calendars from our web application . Everything works for all of our other customers , so I am not sure what is different here except this customer is in Australia and using a non gmail.com email address . The customer is able to authorize our application and w...
Google Calendar returning invalid grant
C_sharp : Is there a way to know what parameters are needed by an event in Visual Studio 2010 ? Let 's say I have a DropDownList control and I want to bind a method to the `` OnSelectedIndexChanged '' , I would do something like thisIn the ASPX File : In the codebehind : Is there a way to know what parameters the metho...
Find the right parameters for an event without using Design Mode in Visual Studio 2010
C_sharp : BackgroundWhile writing a class for parsing certain text , I needed the ability to get the line number of a specific character position ( in other words , count all linebreaks that occur before that character ) .Trying to find the most efficient code possible to achieve this I set up a couple of benchmarks , ...
Method is not inlined by the JIT compiler even though all criteria seems to be met
C_sharp : In C # given a function with the below signatureIf the function was called using Inside the function Foo is it possible to test that the x and y arguments reference the same variable ? A simple equivalent test of x and y is n't sufficient as this is also true in the case two different variable have the same v...
How to Test if C # ref Arguments Reference the Same Item
C_sharp : In a collection of valuesI 'm trying to do with linqIs there someway to do it with linq ? <code> [ 0 , 2 , 25 , 30 ] [ 0 , 0 , 0 , 2 , 2 , 2 , 25 , 25 , 25 , 30 , 30 , 30 ] //Replicate 2 times ( values repeated 3 times )
Insert duplicates values linq
C_sharp : Let 's say I haveSometimes , instead of just sayingI end up doingor maybe evento avoid boxing or copying structs.It works fine and everything , but are there any downsides I do n't know about ( other than a negligible increase in memory usage ) ? Is this an accepted practice , or is it discouraged for any rea...
Using constrained generics instead of interfaces -- downsides ?
C_sharp : So Say I have 2 entities , Post and PostHistory . Whenever I create or edit a post , I want to create an exact copy of it as PostHistory to log all changes made to a post . Say the post entity has the following definition : The problem comes when I create my first Post . For example , if I try this : That wil...
How do I create two associated entities at one time with EF4 Code-First
C_sharp : When writing preconditions for different functions with similar parameters , I want to group assertions or exceptions into a static method , rather than writing them out explicitly . For example , instead ofI would prefer to writeThis feels more natural and helps cut down the code I need to write ( and might ...
Is grouping preconditions into a method acceptable to stay DRY ?
C_sharp : In StructureMap we can proxy TInterface and TConcreteImpl with TProxy this this : I wanted to use DispatchProxy ( and globally log before method invocation and after invocation ) and globally register it for all types being instantiated from StructureMap , I 'm wondering how to accomplish this ? More specific...
StructureMap proxy all instances or modify instances just before returning
C_sharp : I need to add the LinkButton btnAddRow in UpdatePanel upSectionB but the problem is I 'm having this error during load : A control with ID 'btnAddRow ' could not be found for the trigger in UpdatePanel 'upSectionB'.My simplified aspx <code> < asp : UpdatePanel ID= '' upSectionB '' runat= '' server '' UpdateMo...
Update textbox from 1st UpdatePanel using LinkButton from 2nd UpdatePanel 's gridview . Control could not be found
C_sharp : I have an example that I can get to break every time I use an iterator , but it works fine with a for loop . All code uses variables local to the executing method . I am stumped . There is either a fact about iterators that I am not aware of , or there is an honest to goodness bug in .Net . I 'm betting on th...
Why would an iterator ( .Net ) be unreliable in this code
C_sharp : Can anyone explain why the default Asp.Net Web Application template , with Individual user identification , comes with an error in the Manage Controller ? In this code line ; View is Red , because there is no SendVerificationEmail view . Is this normal ? Can this be resolved ? I could specify a view to route ...
Default Asp.Net Core web template comes with error
C_sharp : Please I have a string such as this RemoteAuthorizationTestScope|Start : En Attente Validation|:001|:01195|21/01/2015I can extract the string from the | symbol using this codehowever , there are also text such `` Start : En Attente Validation '' in the string that needs to be separated , how do I achieve this...
Need to extract string from a separator in c #
C_sharp : Is it possible to add the attribute StretchDirection to a VisualBrush ? My VisualBrush contains a media element , and the media element has this attribute , but not the VisualBrush . When I apply the StretchDirection attribute to this MediaElement , it is ignored . I am guessing because VisualBrush is overrid...
Can I add StretchDirection to a VisualBrush ?
C_sharp : I 'm trying to write classes which handle different number types . I know that C # ( and .Net in general , I believe ) has no INumber interface , so I can not use something like the following : That 's okay , though , because I 'd like to avoid the boxing/unboxing of every one of my numbers . I could , howeve...
How can I write a single class to compile multiple times with different number types ?
C_sharp : In my program , you can write a string where you can write variables.For example : The name of my dog is % x % and he has % y % years old.The word where I can replace is any between % % . So I need to get a function where tells which variables I have in that string . <code> GetVariablesNames ( string ) = > re...
How to count the number of occurrences of some symbols ?
C_sharp : I 'm sorry if this is a duplicate but I have n't found anything relevant to it.So , how can I print 0 for the numbers having a whole square root with the following code ? Current O/P : <code> for ( n = 1.0 ; n < = 10 ; n++ ) { Console.WriteLine ( `` Fractional Part : { 0 : # . # # # # } '' , ( Math.Sqrt ( n )...
Printing whole numbers with { # } in C # ?
C_sharp : It appears that default parameters do not work on a readonly struct in c # . Am I misunderstanding something ? Instantiating an instance of this struct using var test = new ReadonlyStruct ( ) ; does not appear to honor the default values . What am I doing wrong ? <code> public readonly struct ReadonlyStruct {...
Can you have default parameters on a readonly struct in c # ?
C_sharp : In this variable , i would like to add some \ before every '.I would like to get that after Replace : Any ideas ? Thanks ! <code> string html = `` < a href=\ '' annee-prochaine.html\ '' > Calendrier de l'annee prochaine < /a > '' html = html.Replace ( `` ' '' , `` \ ' '' ) ; //No changehtml = html.Replace ( `...
Replace ' with \ ' in C #
C_sharp : I have a class called Foo that has a function that looks like the followingBoth Foo and Bar are in a library that I want to reuse in other projects . Now I am working on a new project and I want to subclass Bar . Let 's call it NewBar.What is a simple and flexible way to get Foo.LoadData to return a list of N...
C # Class Factories
C_sharp : consider the following string as inputI need to remove all instances of substring like reference : url , xcon.xfocus.net/XCon2010_ChenXie_EN.pdf ; but this reference : tag is of variable length . Need to search `` Reference : '' keyword and remove all the text till I reach the character `` ; '' .I 've used Re...
Replace substring of variable length from a text file
C_sharp : I 've run into a really strange problem when using the default keyword in a DLL project . In my DLL project ( compiled with VS2013 ) I have the following class : Now , if I use this inside the DLL project , it works perfectly . I can create classes that derive from this base class without issue . But , as soo...
Using default keyword in a DLL
C_sharp : Using WPF and MVVM I 'm trying to display camera images into a Image.Each frame camera got , a callback is called : ViewmodelEach frame , I update the variable _bmpImage : ViewModelIn order to convert the Bitmap to BitmapImage I use a converter : ConverterFinnaly bind to my view : It 's work good the 15 first...
WPF image stop repainting
C_sharp : Lets say i have an array myarr will be of length 13 ( 0-12 Index ) which will also be the length of int [ ] val.I want to check index of myarr where its value is 4 i.e . 1,3,8,11.Then i want One way of doing this is using for loopWe can use Array.indexof but it returns the first index of that value meaning th...
Does LINQ work on Index ?
C_sharp : Currently I have the following block of Rx/ReactiveUI code : As you can see , it flagrantly violates the DRY principle , but I dont know how I could parameterize away the passing of properties and delegates.What is the usual way of automating the creation of these method chains in Rx/ReactiveUI ? <code> this....
How to encapsulate the creation of long reactive chains of observables
C_sharp : Being a computer programming rookie , I was given homework involving the use of the playing card suit symbols . In the course of my research I came across an easy way to retrieve the symbols : gives you ♠ gives you ♥and so on ... However , I still do n't understand what logic C # uses to retrieve those symbol...
Where does ( char ) int get its symbols from ?
C_sharp : I have a block of code where I want to apply the using statement to each command in the commands enumerable . What is the C # syntax for this ? Edit : Rider / ReSharper seems to think these two are equivalent , or at least I get a prompt to convert the for into a foreach ( this is clearly wrong ) : andEdit 2 ...
Await using on enumerable
C_sharp : I have a method in a controller : It responds to /Apps/SendNotification/ { guid } ? { SendNotification properties } SendNotification is a model with multiple string properties . My issue is that SendNotification is NEVER null . No matter how I call the action .NET seems to always instantiate an object of Send...
Optional Parameter always filled
C_sharp : The goalGet one of each result returned by a foreach.The scenarioTake a look in the follow Razor 's code fragment : The return to the client is : Xbox 360Xbox 360Xbox 360Xbox 360Playstation 3Playstation 3Playstation 3Now , let me explain : my application compares the price of products in different stores . In...
Get one of each
C_sharp : Could you please help me understand why variable a is not incremented in the first case but it is in the second case ? Case 1 : Case 2 : I 've gone through other similar questions but could n't find any specifics.UPDATE 1 : How I think the program flowsCase 1 : Case 2 : UPDATE 2 : Thanks to all the answers , ...
Unexpected post-increment behavior in assignment
C_sharp : Why VS complains about this finalizer ? VS 2017 -- 15.3.5Microsoft Code Analysis 2017 -- 2.3.0.62003 <code> using System ; namespace ConsoleApp { class DisposableClass : IDisposable { # if DEBUG ~DisposableClass ( ) // CA1821 Remove empty Finalizers { System.Diagnostics.Debug.Fail ( `` Forgot Dispose ? `` ) ;...
CA1821 Remove empty Finalizers
C_sharp : What is the cause for the second case ? I know I cant cast a boxed enum to int ? directly , but I do a two stage casting , ie Cast < int > .Cast < int ? > which should be working.Edit : This is surprising considering the below works : <code> enum Gender { Male , Female } var k = new [ ] { Gender.Male } .Cast ...
Cast < int > .Cast < int ? > applied on generic enum collection results in invalid cast exception
C_sharp : I have downloaded the source code files from here of a magnifier glass effect : http : //www.codeproject.com/Articles/18235/Simple-MagnifierAnd this is the main Form code : Now it will work on two cases : The mouse should be on the Form area on the magnifier glass icon.The mouse button left button should be p...
How can I make the effect to be shown only when moving the mouse ?
C_sharp : To check the validity of a Binary Search Tree , I use a method . But the method always returns false , when tested against a valid Binary Search Tree.Online Demo HereThe code <code> public class Program { public static void Main ( ) { BinarySearchTree < int > tree = new BinarySearchTree < int > ( ) ; tree.Ins...
Is Valid Generic Binary Search Tree with Recursion
C_sharp : I am developing an application that using IDocumentClient to perform query to CosmosDB . My GenericRepository support for query by Id and Predicate.I am in trouble when change Database from SqlServer to CosmosDb , in CosmosDb , we have partition key . And I have no idea how to implement repository that suppor...
Repository that support query by partition key without change interface
C_sharp : In the constructor of an object , Listener , we take an argument and subscribe to one of its events . If an exception is thrown within the constructor after the event is subscribed the OnSomethingChanged ( ) method is still called when the event is raised - even through the object was not successfully constru...
Local event listener called even though object failed to be constructed
C_sharp : I have groups of logic that consist of static classes such as : In this case , A and B are static classes that implement the same behavior via a group of functions ( e.g . mutate ) . I would like to use something like an interface for this pattern , however since static classes can not implement interfaces I ...
grouping static classes with the same behavior
C_sharp : I 've been working on a calculator using C # and came across an issue I have n't been able to work past.Currently when a user enters a number divided by zero then the answer defaults to 0.00 when instead it should be invalid.I have no idea why and after tinkering with it for awhile I have n't been able to fig...
Why is my `` Divide by Zero '' prevention not working ?
C_sharp : I have application based on this tutorialMethod I use to get user list from service : Service main function : Other classes are inClasses.csMy question is : why I ca n't send anything that is not generic type ? I need to send List < User > or User [ ] but I ca n't even send int [ 2 ] ( sending int or string i...
Ca n't send anything that is not generic type
C_sharp : Basically , I have the following scenario : But , the problem I see here is that I could have done ConcreteFooB : FooBase < ConcreteFooA > { ... } , which would completely mess up the class at runtime ( it would n't meet the logic I 'm trying to achieve ) , but still compile correctly.Is there some way I have...
Is it possible to programmatically enforce a derived class to pass itself into a base class as the generic type ?
C_sharp : I 'm making a Rebar wrapper for .NET . Here 's how I 've made my control.I tested my control by adding a REBARBANDINFO into the control and IT WORKED.I wo n't include the implementation of my p/invoke signatures because everything is fine there.The problem starts hereThe control does n't work the way I 've ex...
How can I let .NET wrapper for Rebar decide the mouse cursor ?
C_sharp : I am relatively new to using TDD and have been reading about mocking objects lately . I have the following test to test a method that given a date returns the next saturday . first off , does this represent good testing practices ? Second , what is the advantage of utilizing a mock framework to create this te...
Should I use mocking for the following example
C_sharp : I have a simple AngularJS $ http block like so ; My issue is that when my ASP.NET Controller returns a HTTP error code , the JS errorCallback receives an object like ; No matter what I do , I ca n't seem to populate the data property in my callback.If instead my controller returns a HTTP OK code , then the 's...
AngularJS $ http ( ... ) errorHandler receives empty string for data
C_sharp : If I Invoke a method onto the UI Thread is it searilized by the Windows message queue and subsequently does n't need to be re-entrant ? Clarification : It is only the UI thread that will be accessing _counter . <code> private void CalledFromWorkerThread ( ) { //changed from 'InvokeRequired ' Anti-Pattern this...
Does a method marshalled on the UI Thread need to be thread-safe
C_sharp : Edit : Please read carefully , I have and issue Loading data for without cartesian production . Deleting data works fine if the references are loaded properly . I 'm trying to delete a large group of entities , However due to a many-to-many assoication OwnerRoles whenever I try to delete them I receive an err...
Entity Framework Reference constraint error on delete when using selectmany
C_sharp : EDITI took Jon 's comment and retried the whole thing . And indeed , it is blocking the UI thread . I must have messed up my initial test somehow . The string `` OnResume exits '' is written after SomeAsync has finished . If the method is changed to use await Task.WhenAll ( t ) it will ( as expected ) not blo...
How does the runtime know when to spawn a thread when using `` await '' ?
C_sharp : I tried the following to detach a graph of entity objects , and then attach it to a new context : I have two issues with this approach : After detaching all entity objects , newParent.Children becomes emptyAn InvalidOperationException is raised when re-attaching saying that `` An entity object can not be refe...
Can a graph be detached from an ObjectContext and be re-attached to another one ?
C_sharp : I have seen on various websites how developers version their css/javascripts files by specifying querystrings similar to : How is that done ? Is it a good practice ? I 've been searching around but apparently , I 'm not looking for the right terms . If it matters , I 'm using ASP.NET.Edit : : I just noticed (...
How to version files in the < HEAD > section ?
C_sharp : I 'm building a small chat program that consists of a server and client . The server keeps a list of clients that it interacts with.I 've got two worker threads on the server . One handles incoming client connections . The other handles incoming client messages.Now , since both threads interact with a List ca...
Is this a correct use of multithreading design ? ( C # )
C_sharp : I have a List of Objects and within the Object there is a List of strings . What I want to do is find out how many of each string value there are.So to create a simple example with the languages spoken by people in a team.Create the test data ... To visualise the data : I can get the result I want by finding ...
c # linq GroupBy on the values of a List within a List
C_sharp : I have the following script : And I need to return the following XML : The idea is that I will convert the XML into a DataSet with 2 DataTables ( one for Columns and the other for Rows ) . I will use this to populate a DataGridView.However , my problem is that the XML I 'm generating currently is malformed an...
How to return multiple tables as one XML ?
C_sharp : Most of the applications consuming my add-in return `` C : \Users\ [ username ] \AppData\Local\Temp\ '' path . But one application is returning `` C : \Users\ [ username ] \AppData\Local\Temp\1affa5dd-2f26-4c96-9965-7a78f5c76321\ '' . The GUID in the end changes every time I launch the application.The applica...
Path.GetTempPath ( ) method returns UserTempPath with GUID in the end when using Revit 2020
C_sharp : I basically want two separate overloads for string/FormattableString ( the background is that I want to nudge people towards using string constants for log messages and pass parameters via structured logging instead of the log message to simplify analysis . So the FormattableString logging method would be obs...
Overload Resolution with implicit conversions
C_sharp : I 'm inserting a special ( summary ) row into a DataTable , and I want it to appear last in a sorted DataView . I know the DataView is being sorted ( ascending ) by a particular string column , and for display purposes it does n't matter what value appears in that column of the summary row.What string can I p...
Who is the greatest among all strings ?
C_sharp : In my class I have these setters/getters : DateTime is a non-nullable type . So , when I retrieve my data from my legacy database that I pass to the class constructor , I get an error when the StartDate is null.How should I go about designing around this ? ThanksEric <code> public int Id { get ; set ; } publi...
How to design class around null values from database ?
C_sharp : I 'm currently dealing with 2 systems that expose interop via their own RESTful JSON APIs . One is in C # with JSON.NET and one is Java Spring Boot Starter ( Jackson JSON ) . I have full control over both systems.Both systems need to transfer JSON data with reference handling . Whilst both JSON serialization ...
Dealing with JSON interop between Java and C # REST APIs
C_sharp : I refer to the Examples in How to : Combin Data with Linq by using joins . We have two Lists the first holds person objects ( First- and Lastname ) . The second List holds Pet objects ( Name ) that holds a person object ( pet owner ) . One Person can own > = 0 pets . What happend now is I performed the group ...
Does Linq produces redundancies ?
C_sharp : I have tried two ways but they both didnt work..the first way : :the second way : :is there something wrong i dont see ... my xml file looks like this : :and i used a query string to load the values from a gridView located in another page using `` QueryString '' ... .thanks in advance . <code> string filepath...
xml nodes editing based on an xmlElement
C_sharp : In my application I want to join multiple strings with a dictionary of replacement values . The readTemplateBlock gets fed with FileInfos and returns their contents as string.The getReplacersBlock gets fed ( once ) with a single replacers dictionary.The joinTemplateAndReplacersBlock should join each item of t...
A datablock to join a single result with multiple other results
C_sharp : IntroI am working with a complex external library , where I am attempting to execute it 's functionality on a large list of items . The library does not expose a good async interface , so I 'm stuck with some quite old-fashioned code . My aim is to optimize the time it takes to complete a batch of processing ...
Time optimization of parallel long-running tasks
C_sharp : If a dependency container , or data access factory , can return types that may implement IDisposable , should it be the client 's responsibility to check for that and handle it ? In my code below , one data class implements IDisposable and the other does n't . Either can be returned by the data access factory...
Polymorphism when concrete types *might* be disposable
C_sharp : I want to declare several constant objects that each have two subobjects , and I 'd like to store these in an enum for organizational purposes.Is it possible to do something like this in C # ? <code> enum Car { carA = { 'ford ' , 'red ' } carB = { 'bmw ' , 'black ' } carC = { 'toyota ' , 'white ' } }
Is it possible to create an enum containg arrays ?
C_sharp : I 'm trying to estimate the widths in pixel if a text would be rendered in Chrome by using C # for a specific font ( Arial 18px ) in a tool that I 'm creating.Comparing my results with this tool ( uses the browser to render the width ) : http : //searchwilderness.com/tools/pixel-length/ the string : Is calcul...
C # : Pixel width matching text rendered in a browser
C_sharp : Followup to this question : Why is Nullable < T > considered a struct and not a class ? I have two classes that essentially maintain a tuple of some user-supplied value with an internal object.When the type of the user-supplied value is a primitive , I have to wrap it in a Nullable < T > so that it can take o...
Is there any way to combine these almost identical classes into one ?
C_sharp : This is more of a C # syntax question rather than an actual problem that needs solving . Say I have a method that takes a delegate as parameter . Let 's say I have the following methods defined : Now if I want to call TakeSomeDelegates with FirstAction and SecondFunc as arguments , As far as I can tell , I ne...
Is there any way to use C # methods directly as delegates ?
C_sharp : My main page sends an API request in async way and then sets the main page to some other other page like this : These are my WebView events : Now the problem is when the page containing WebView is set to main page when app starts it is opening the website fine . But when it is set from another main page then ...
Trying to change MainPage but WebView on the new page fails to load site . But it is successful when I set it as the main page when application starts
C_sharp : I just bumped into a really strange C # behavior , and I ’ d be glad if someone could explain it to me.Say , I have the following class : As I get it , in the line of commentary I have the following objects in my field of view : len variable and call.Inside of lambda , I have local parameter len and Program.l...
Lambda capture parameter provoking ambiguity
C_sharp : Suppose to have a polygon class like this one : To make triangles , squares , hexagons would you rather : Inherit from Polygon your Triangle , Square , etc . class that provides aspecific constructor and generate points programmatically ? Add a CreateSquare static method that returns a ready to use Polygon cl...
OOP object creation guidelines
C_sharp : I am trying to render a simple view with the TinyWeb framework and Spark view engine.Enviroment is Visual Studio 2011 developer preview & .net 4.5Rendering a template with no model binding works fine.However when I bind a model then it no longer works.I get this error : The name 'Model ' does not exist in the...
Can not render view in TinyWeb framework
C_sharp : Update : Heinzi is right . AutoCAD Polyline is reference type and not a struct . Good point . But I have simplified the scenario as what I am dealing with in the real application is an AutoCAD object which is struct . So please consider both as struct not reference type.I am looking for the right approach to ...
Using generic in the interface
C_sharp : I want to store Sub instances in a collection . However , to get it to actually work , I have to declare an interface and store instances of that interface.Is there a more elegant way of doing this ? <code> class B : A { } class Sub < T > where T : A { // ... } var c = new List < Sub < A > > ( ) ; c.Add ( new...
Generics and casting
C_sharp : I have this problem : I want to generate a new source code file from a object information.I make something like this : dictParamMapping is a Dictionary < string , Type > where the string is a variable name and Type is the type of that variable.I get the type to build new code using : When Type is int , string...
How to reuse Type returned value to generate new source code
C_sharp : I 'm currently using Visual Studio ( specifically , 2012 Express ) . I have an interface already defined as follows : If I have an empty class : And I right-click on the IMyInterface , I can select `` Implement Interface '' . When I do this , the auto-generated code produces the following : My question is , i...
How can I prevent the generated implementation of an interface from using a type alias ?
C_sharp : I 've been working on a project for a client and had a lot of fun integrating SignalR into the system.Everything seems to work really well and the client is really excited about how the SignalR gives true real-time feedback for their application.For the most part everything has gone swimmingly , however I 've...
SignalR client calls fail for certain languages
C_sharp : I have a DoDragDrop where I set the data to a Point.when I drag within one instance – everything 's OK . But when I drag between two instances of the program Visual Studio gives me this error : The specified record can not be mapped to a managed value class.Why ? EDIT : here 's the code : And : <code> DataObj...
Why ca n't I drag a Point between two instances of a program ?
C_sharp : First , excuse the rather funny name of my question . I 'm no native speaker and it took me 10 minutes to express my thoughts in these few characters.What I 'm trying to do is to create a dictionary in C # that allows the value to be either an int , a string or a bool . What first had come to my mind was usin...
Dictionary with limited number of types
C_sharp : Say , we have 2 classes : Then whyThe same for explicit operator.P.S . : casting each element manually ( separetely ) works <code> public class A { public int a ; } public class B { public int b ; public static implicit operator B ( A x ) { return new B { b = x.a } ; } } A a = new A { a = 0 } ; B b = a ; //OK...
Why Enumerable.Cast does not utilize user-defined casts ?
C_sharp : ( let 's assume I have 10 cores ) When I write : Questions : What is the formula of assigning amount of numbers to each core ? ( is it 100/10 ? ) At execution point , does each core already know which numbers is is gon na handle ? Or does it consume each time a new number/s from the [ 0..100 ] repository ( le...
Parallel and work division in c # ?
C_sharp : Here I have a list from my class AssinantesAnd I needed to group by City , ClientCod and Num , which I 've already done here : Then , I needed to generate an html string with Linq , like the example below : Could somebody give me any sugestion ? <code> new Assinante { City= `` BAURU '' , Num= 112 , ClientCode...
How do I generate an html string from group by
C_sharp : I have a problemI have a table with 44839 recordsBut when I try to load my table through EF with this code : I only get 16311 recordsBut when I use this I get all my recordsWhy is this happening ? ? <code> dbContext = new MyDbContext ( `` MyContext '' ) ; dbContext.SalesRegister.Load ( ) ; BindingList < Sales...
Entity Framework Load ( ) method does n't load everything
C_sharp : FINAL EDITI 've more thoroughly tested the `` feature '' and written a complete article about it : Optional passed by reference parameters with C # for VBA COM APIsAny feedback is welcome.For whatever reason in C # a method ca n't have optional passed by reference ( marked with ref or out ) parameters.But in ...
Possible nasty side effects of tricking .Net to have optional ref parameters for COM
C_sharp : I have custom class deriving from a library ( Satsuma ) like so : and a Neighbors method in the library that returns List < Node > . I want to be able to do this : But Any sees n as a Node , not DCBaseNode , so it does n't understand .selected.So I tried : ... which gives me this error : Error CS1928 : Type S...
C # - Error CS1928 : Checking for list element with derived class
C_sharp : This code works : ... and so does this ( with the same result ) : Is there a reason to prefer one ( First , or Find ) over the other ? UPDATESo , using Reed 's suggestion , all I need is this : ... and it 's safe / it fails gracefully ( or not at all , of course , when provided a proper ID val ) . <code> publ...
Is Find preferred over First , or vice versa , in LINQ ?
C_sharp : We have a web ASP.NET application with target framework 4.5.1 , which references some library built with target framework 2.0 . So , 4.5.1 can use 2.0 , that 's okay.But both app and library uses log4net 1.2.11 and app uses package for 4.0 framework , when library uses package for 2.0 framework.Here how it lo...
How target framework really works ( and why lib for 2.0 can use lib for 4.0 ) ?
C_sharp : I want to add a form-feed to my panel after each Item that I print so that I can have each Item print on its own page.Is that even possible to do ? For example I can add a line-break to my panel but not sure how to add a form-feed.Example : Any help would be appreciated.Thank you <code> Panel1.Controls.Add ( ...
Is it possible to add a form-feed to an asp.net panel ?
C_sharp : How can i work with Array in Object ArrayPlease see picture for more info : I use from forech for get Object and then i want to work with Array in Object but it 's not possibleI want to get value from array and work with them for example i want to get `` TestCategory_1 '' or etc but i ca n't now how can i wor...
work with array in object array
C_sharp : I am trying to understand need for static constructors . None of information I found answered following question I have . Why would you do thisas opposed to this ? This is not dupe of other question , this is about static constructors which do n't accept parameters . <code> class SimpleClass { // Static varia...
Trying to understand static constructors
C_sharp : I want DateTime in the following format.Output : I want to subtract 4 hours from this time . So I have used this line of code : Now , not only is the wrong time being shown , the above format is also disturbed.Expected Output : <code> DateTime a = Convert.ToDateTime ( DateTime.UtcNow.ToString ( `` s '' ) + ``...
DateTime.AddHours gives wrong output and datetime format changes
C_sharp : So , I know very little about decorators / adorners , but was given a great answer here which uses them.I have tried to implement them , but they ust dont seem to work as they do for the person who gave the answer . I have tried to keep everything as identical as I can.Here is my XAML : Here is the Adorner cl...
Why wont my custom decorator / adorner function when bool changes to true ?
C_sharp : Consider the following code snippet , a traversal of a three dimensional array of singles , in terms of execution efficiency , assuming that process1 ( ) and process2 ( ) take identical lengths of time to execute : Now , it 's known that C # organizes arrays in the .NET framework as row-major structures . Wit...
.NET Compiler -- Are there nested loop optimizations built-in ?
C_sharp : I want to underline a word with a round brace . This should be part of a C # Text but if it is easier in CSS , no problem . My problem is that the length of the Word can vary , so the bow must by calculated for each word.My first idea was using CSS box-shadow : CSS : HTML : Unfortunately due to the dynamic Te...
Dynamic text underlined by braces
C_sharp : Is there a way to change `` ABCDEFGHIJKLMNOP '' to `` ABCD-EFGH-IJKL-MNOP '' using string.format ( ) function or perhaps LINQ ? I am using this statement is there a better and clearer way to accomplish this ? <code> Out= String.Format ( `` { 0 } - { 1 } '' , String.Format ( `` { 0 } - { 1 } - { 2 } '' , In.Su...
What is the best way to separate string using string.format ( ) function or LINQ ?
C_sharp : Dabbling in reactive programming , I often encounter situations where two streams depend on each other . What is an idiomatic way to solve these cases ? A minimal example : There are buttons A and B , both display a value . Clicking on A must increment the value of A by B. Clicking on B must set the value of ...
Cycling dependencies between streams in reactive programming
C_sharp : Today I tested the following code in Visual Studio 2010 ( .NET Framework version 4.0 ) And I was shocked to find these two on the list : System.Collections.Generic.IReadOnlyList ` 1 [ [ System.Int32 , mscorlib , Version=4.0.0.0 , Culture=neutral , PublicKeyToken=b77a5c561934e089 ] ] , mscorlib , Version=4.0.0...
How can Type int [ ] implement interfaces that do not yet exist ( for me ) ?
C_sharp : I have an object model that has a property like this : I want the DoSomeWork function to execute automatically after the SomeString property changes . I tried this but it 's not working : What 's the correct syntax ? <code> public class SomeModel { public string SomeString { get ; set ; } public void DoSomeWo...
Setting only a setter property
C_sharp : There is DataTable with primary key to store information about files . There happen to be 2 files which differ in names with symbols ' 4 ' and ' 4 ' ( 0xff14 , a `` Fullwidth Digit Four '' symbol ) . The DataTable fails to include them both because of failed uniqueness . However , in Windows filesystem they s...
' 4 ' and ' 4 ' clash in primary key but not in filesystem
C_sharp : For example . Lets say we have a stackpanel on a form . Its full of both Grids and Labels . I want to loop through all the Grids and do some operation on them but leave the Lables intact . At the moment I am doing it this way.So i 'm using the fact that `` as '' returns null if it can not cast into the requir...
Using `` as '' and expecting a null return
C_sharp : I have a small Dotnet core program ( 3.1.8 ) , with some FileWatchers.They watch folders on a network drive.With some load ( 200 - 250 files maximum here ) , the program crashes unexpectedly.These files come at the same time , moved by another process on another server thanks to a Biztalk app , I do n't think...
.NetCore - FileSystemWatcher on a network drive , unsafe code Win32 API crash