text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : In C # 7.2 , are readonly structs always passed to functions as if the `` in '' parameter is present ? If not , in what case would it be useful to copy the memory given that it 's readonly ? I have a readonly struct : So would there be a performance difference between these two methods when called billions of... | Is it necessary to use the `` in '' modifier with a readonly struct ? |
C_sharp : I recently wrote this and was surprised that it compiles : If I use this class as follows , I get an `` Ambiguous constructor reference '' and an `` Ambiguous invocation '' if I call Add.Obviously , there 's no ambiguity when I use int and double as generic types , except of course when I use both ints , whic... | Generics in C # with multiple generic types leads to allowed and disallowed ambiguity |
C_sharp : I 'm developing a class library which should be licensed to specific developer computers . There are no components so that the design time licensing checks ca n't be done . This check is in fact unavailable for pure class libraries : One has suggested to use Debugger.IsAttached to check if the lib is used on ... | execute method from referenced class library before build .NET application for license checking |
C_sharp : just messing around with the unsafe side of c # Is it possible to assign a string literal to a char pointer just like in C or do I have to do it as in the above snippet ? <code> unsafe { char* m = stackalloc char [ 3+1 ] ; m [ 0 ] = ' A ' ; m [ 1 ] = ' B ' ; m [ 2 ] = ' C ' ; m [ 3 ] = '\0 ' ; for ( char* c =... | Assign a string literal to a char* |
C_sharp : I have the following -Problem being that the value of i passed into ProcessResult seems to be the value when it starts , not the value of the iteration when it is created.What is the best way to protect against this ? <code> for ( int i = 0 ; i < N ; ++i ) { var firstTask = DoSomething ( ... ) ; var task = an... | Using anonymous methods inside of a delayed task inside of a loop |
C_sharp : I 'm using Microsoft 's Entity Framework as an ORM and am wondering how to solve the following problem.I want to get a number of Product objects from the Products collection where the Product.StartDate is greater than today . ( This is a simplified version of the whole problem . ) I currently use : When this ... | Why does EntityFramework 's LINQ parser handle an externally defined predicate differently ? |
C_sharp : I 'm trying to convert this long JS regex to C # .The JS code below gives 29 items in an array starting from [ `` '' , '' 常 '' , '' '' , '' に '' , '' '' , '' 最新 '' , '' 、 '' , '' 最高 '' ... ] But the C # code below gives a non-splitted single item in string [ ] .Many questions in Stack Overflow are covering re... | C # Regex.Split is working differently than JavaScript |
C_sharp : Just curious , is changing the size of a struct/value type a breaking change in C # ? Structs tend to be more sensitive in terms of memory layout since altering them directly affects the size of arrays/other structs . Are there any examples of code that breaks , either binary-wise or source-wise , after the l... | Is changing the size of a struct a breaking change in C # ? |
C_sharp : I have a string : Apple1231|C : \asfae\drqw\qwer|2342|1.txtI have the following code : What I want to be able to do is replace every | after the first | with \So i want to write out Apple1231|C : \asfae\drqw\qwer\2342\1.txt <code> Regex line2parse = Regex.Match ( line , @ '' ( \| ) ( \| ) ( \| ) ( \d ) '' ) ;... | C # Regex replace help |
C_sharp : I have the following statement : I want to check and see if card.Details is null or empty ... if not , write the value . Is there any syntax that allows me to leave out the else conditional ? <code> serverCard.Details = ! String.IsNullOrEmpty ( card.Details ) ? card.Details : serverCard.Details ; | How to simplify this C # if/else syntax |
C_sharp : I 've read a fair amount of posts on the subject , and I think I finally understand how the volatile keyword works in C # . Still I wanted to ask here just to make sure I understand the concepts properly . Consider the following code : From what I understand , if another thread were to set Enabled=false , the... | Using volatile for one-way communication between threads in .NET |
C_sharp : I have been looking in to you some code was n't working . Everything looks fine except for the following line.Before that line is executed Transport is null . I see the GetMock executed and that it returns a non null object . After that line Transport is still null ; I looked at the IL that was generated an i... | Is the JIT generating the wrong code |
C_sharp : I have an abstract class called EntityTypeTransform with a single abstract method designed to hold a Func delegate that converts an IDataRecord into an instance of T.An implementation of that class might look like ( does look like ) this : Now I want to keep an instance of each of these classes in a generic D... | Keep a Dictionary < Type , MyClass < T > > where elements are referenceable by type |
C_sharp : Is there a make_tuple equivalent for C # /.NET ? I want to do something like thisC # seems to support it when i create my own functionBut msdn tuple shows not using itIs there or is n't there ? I can use 4.5 <code> mylist.Add ( new Tuple < string , int > ( `` '' , 1 ) ) ; Tuple < T , U > make_tuple < T , U > ... | Is there a make_tuple for C # ? |
C_sharp : I have this string : '' B82V16814133260 '' what would be the most efficient way to get two strings out of it : left part String : `` B82V '' rigth part string : `` 16814133260 '' The rule is this : take all numbers on the right side and create string out of them , then take the reminder and place it into anot... | the most efficient way to separate string |
C_sharp : String interpolation is great and snippets are great , but they do n't play nice together . I have a snippet that looks ( in part ) like this : The locationfield part is supposed to be the replacement , but of course it will see as ' '' { e [ `` being a replacement . So when you try to use the snippet , that ... | How to escape string interpolation in snippet |
C_sharp : Here 's a simple application that prints the method signature of a MethodCallExpression : I would expect the program to print out : But it instead prints out : When getting the Method property for the inherited MethodCallExpression , it always returns As MethodInfo ( the root class ) .However , in Visual Stud... | MethodCallExpression.Method always returns the root base class 's MethodInfo |
C_sharp : I noticed most of the developers are using event for callback and I 'm not sure whether I 'm doing in a right way.I noticed most of developers ' codes look like this : While the way I do `` event '' look like this : I hope someone could explain to me what 's the differences between both codes ? Which way of d... | Which is the correct/better way of Delegate declaration |
C_sharp : I 'm trying to insert some data into my DB ( Microsoft SQL Server ) My connection does not open and I get this message : Can not open database \ '' [ Sales and Inventory System ] \ '' requested by the login . The login failed.\r\nLogin failed for user 'Mostafa-PC\Mostafa'.here is my code : I 've done everythi... | can not open database - requested by the login - why ca n't I connect to my DB ? |
C_sharp : The following code is very repetitive : However , my attempt to use generics does not compile : The error message is as follows : Error 2 Operator '- ' can not be applied to operands of type 'T ' and 'T ' C : \Git ... \LinearInterpolator.cs How should I reuse my code ? Edit : fast runtime is important for thi... | How to use generics to develop code that works for doubles and decimals |
C_sharp : Could someone explain to me why this piece of code is doing well when I execute it on a x86 platform and why it fail on x64 ? Results : x86 Debug : 12345678910x64 Debug : 12345678910x86 Release : 12345678910x64 Release : 1111111111If I change something , like removing one of the unused variables , or if I rem... | Variable is not incrementing in C # Release x64 |
C_sharp : Everybody knows that asynchrony gives you `` better throughput '' , `` scalability '' , and more efficient in terms of resources consumption . I also thought this ( simplistic ) way before doing an experiment below . It basically tells that if we take into account all the overhead for asynchronous code and co... | Does asynchronous model really give benefits in throughput against properly configured synchronous ? |
C_sharp : I have a Window with few controls on it . One of them is a DataGrid . I want to implement some non-default focus traversal . Namely : DataGrid is a single stop as a whole , not each row.When DataGrid is focused , user can navigate through rows using up and down keys.Navigating through columns using left and r... | How to make DataGrid a single stop as a whole on focus traversal with arrow keys row selection ? |
C_sharp : I 'm creating project in ASP.NET ( Framework 4.0 ) . I have used Asp LinkButton in Master Page & it has 2 page linked with it ( Home.aspx & service.aspx ) .Question As follows : That LinkButton1 works on Home.aspx and does n't work on service.aspx.User.master code as followUser.master.cs code for LinkButton1 ... | LinkButton on Master Page does n't fire on Second Child Page in ASP.NET |
C_sharp : How to document the classes & properties & functions that are generated automatically using LINQ to SQL DBML ? I managed to provide documentation to the datacontext class by defining the same partial class in another file with < summary > so it wo n't be removed if the DBML got refreshed This would work for t... | C # XML documentation of Linq to SQL |
C_sharp : I 'm making a pong game . I 've been using a simple 44 x 44 .png of a red square as my ball while I 've been debugging . The game works fine with this square.When I try to replace the texture with anything other than a square , I do n't see the ball drawn on screen , and I ca n't figure out why . I 'm making ... | Can not draw image over than square in XNA |
C_sharp : I have the following ugly code : Is there a way to chain check for null values in C # , so that I do n't have to check each individual level ? <code> if ( msg == null || msg.Content == null || msg.Content.AccountMarketMessage == null || msg.Content.AccountMarketMessage.Account == null || msg.Content.AccountMa... | Is there such a thing as a chained NULL check ? |
C_sharp : Why does url decode not get an error when it decodes % 22 . This is a double quote . When a programmer enters a double quote in a string syntactically they must use two double quotes `` '' to represent a double quote.For ExampleOutputIt '' s nice to meet youBut when url decodes a double quotes why does it not... | What is the logic behind url decoder when using double quotes ? |
C_sharp : I 'm working in a code base which has a lot of first class collections.In order to ease using these collections with LINQ , there is an extension method per collection that looks like : With the accompanying constructors : This winds up being a bunch of boilerplate so I attempted to write a generic IEnumerabl... | Generic extension method to convert from one collection to another |
C_sharp : I want to chunk a credit card number ( in my case I always have 16 digits ) into 4 chunks of 4 digits.I 've succeeded doing it via positive look ahead : But I do n't understand why the result is with two padded empty cells : I already know that I can use `` Remove Empty Entries '' flag , But I 'm not after th... | Split credit card number into 4 chunks using Regex lookahead ? |
C_sharp : I usually use many EF Core async methods in my web application like this : As we know , initial number of threads in ThreadPool by default is limited to number of CPU logical cores . Also user requests are handled by threads in ThreadPool . Should I worry about handling user requests or performance issues due... | Do Entity Framework async methods consume ThreadPool threads ? |
C_sharp : The following code produces a syntax error : However , the following alternatives both work : Why is this so ? ( foo.a ) is an Action ; why ca n't I call it ? <code> class Foo { public Action a = ( ) = > { } ; } void doSomething ( ) { var foo = new Foo ( ) ; ( foo.a ) ( ) ; // error CS1525 : Invalid expressio... | Why is it invalid syntax to call an Action member in this way ? |
C_sharp : I have to do a search to return a value , I have to do is the sum of multiplying two fields.I have the following code : It is giving the following error : the variable 'acct ' type 'tem ' is referenced in scope `` , but it is not setHow can i return this value ? <code> internal double TotalRes ( long Id ) { d... | Make a multiplication in a SQL |
C_sharp : I 'm trying to write the following method using generics . ( My actual method is more complex than this . ) My goal is to return something like null if the item is not in the dictionary.The problem is that I do n't know what type T is . If T was an integer , for example , then I should return the type T ? . H... | Returning Null Value for Unknown Type |
C_sharp : I have some code that when called calls a webservice , queries a database and fetches a value from local cache . It then combines the return values from these three actions to produce its result . Rather than perform these actions sequentially I want to perform them asynchronously in parallel . Here 's some d... | c # threading async problem |
C_sharp : I tried to convert the default template for `` Service Fabric Applicatoin '' with `` Actor Service '' from C # to F # . Here is the github repo.I can compile everything but when I deploy it to the local cluster I get System.ArgumentNullException . Does anyoune know what is wrong here ? Here is the stack trace... | Service Fabric with F # not working |
C_sharp : I have a class containing a collection of items . For convenience I 've provided GetCurrentItem which is implemented bywhich will throw an exception if there are no items in the list . Should I let the exception be thrown or should I return null ? If this was an API I handed to you , what would you expect ? T... | Creating property which may throw IndexOutOfRangeException |
C_sharp : I 'm sure I 've seen this in various exception messages in the framework . I checked the following pages from the MSDN library but could not find much guidance for the message contents : Exception ThrowingError Message DesignException.Message PropertyThe only part in the first page that could explain it is th... | Why do built in exception messages tend to not have specific details ? ( e.g . key from a dictionary ) |
C_sharp : Code contracts simply treats Tasks as it would with any other variable , instead of waiting for the result asynchronously . So , the following scenario will not work , and cause a Contracts exception since at the time the method returns , its an incomplete task , and the results would n't be set at that point... | Code Contracts and Tasks |
C_sharp : I have wrote the following code : resharper shows me a warning : Possible duplicate enumeration of IEnumerableWhat does this mean ? Why is this a warning ? <code> IEnumerable < string > blackListCountriesCodes = pair.Criterion.CountriesExceptions.Select ( countryItem = > countryItem.CountryCode ) ; IEnumerabl... | Possible duplicate enumeration of IEnumerable |
C_sharp : I have a class which has been steadily growing over time . It 's called LayoutManager . It started as a way for me to keep track of which dynamically created controls were on my page . So , for instance , I have this : In this way , during the beginning stages of the Page Lifecycle , controls would be re-crea... | Trying to shy away from a singleton/god/manager class . Not sure how I am supposed to sustain functionality , though |
C_sharp : Few Days back , I faced a test where I was asked to answer the following question : Though it seems basic , I 've some doubt and my own opinionA publication center publishes books . A writer can write many books and a book has a authorThere were four options and among them , I omitted two options that were n'... | List Vs Array : One-To-Many and Has-A Relationship |
C_sharp : I 've come across the problem regarding asynchronous tasks in a dictionary in a couple programs now , and I ca n't wrap my head around how to solve it.I have an asynchronous task that looks like this : MessageEventArgs is a class from a 3rd party library that I declare statically at the start of my program : ... | Referencing asynchronous tasks in a c # dictionary |
C_sharp : I am working on a `` learning program '' and using the Code Rush refactoring tool with my learning . With the latest update of Code Rush it has been recommending implementing IDisposable to my programs . I know what MSDN says about IDisposable and I have a real basic understanding of what it does but because ... | What is this IDisposable doing for me ? |
C_sharp : I ca n't understand how to solve the problem that the teacher gave me . Given a number N ( 0 < = N < = 100 ) , find its first digit . For example : It seemed easy at first , but ( as the teacher said ) it should be done using ONLY integer data types ( in other words , using + , - , * , / and % operators ) . I... | Find first digit of a number using ONLY integer operations |
C_sharp : I am unsure of whether what I am doing is completely invalid or merely poor practice , but I have a class , let 's call it Bar , which is a field of some parent class , let 's call Foo , and one of Bar 's methods requires that I pass the instance of the parent Foo as an argument . This seems like a terrible a... | How to deal with passing a parent object as an argument ? |
C_sharp : So I see that Assert has dozens of methods that seem to do essentially the same thing . Why ? Is it just to be more explicit ? When should the various methods be used ? Is there an offical best practices document ? <code> Assert.IsFalse ( a == b ) ; Assert.IsTrue ( a ! = b ) ; Assert.AreNotEqual ( a , b ) ; | Why does the `` Assert '' class have so many seemingly redundant methods ? When should each be used ? |
C_sharp : I am trying to load some BitmapImages from files held on the file system . I have a dictionary of keys and relative filepaths . Unfortunately the Uri constructor seems non deterministic in the way that it will load the images.Here is my code : Unfortunately sometimes the Uris get loaded as relative file Uris ... | c # Uri loading non deterministic ? |
C_sharp : I have the following scenario when grouping a collection : where data variable is of type ObservableCollection < Data > When I check forit throws an IndexOutOfRangeExceptionof course this happens because the string split operation throws an exception.The question is : is there a way to check if the result of ... | C # IEnumerable.Count ( ) throws IndexOutOfRangeException |
C_sharp : What are the differences between this two methods that seems to do the same thing ? Can it be done even with async/await ? <code> public Task < int > TaskMaxAsync1 ( Task < int > [ ] my_ints ) { return Task.WhenAll ( my_ints ) .ContinueWith ( x = > x.Result.Where ( i = > i % 2 ! = 0 ) .Max ( ) ) ; } public Ta... | C # Differences between Result and ContinueWith |
C_sharp : I have a list of strings which holds file paths . I have another list which holds a subset of files – but it has only the file name ; not the path.Now I need to get files from allFilesWithPathList that is not present in excludeList . Currently I am doing the following , using EXCEPT , after creating another l... | Except with LIKE condition in LINQ |
C_sharp : The reason I am asking is because I wrote an extension method to use in Silverlight only to find out that feature magically started working for silver light . Example Why is there a special System dll in the framework for Silverlight that does the comparsion as case insenstive ? I have run into this for tons ... | Is there a reason why System dll is different in Silverlight and other C # Libraries |
C_sharp : In VB you can have this : But in C # , you ca n't do this : Because you get an error `` Keyword 'this ' is not available in the current context '' .I found this question/answer which quotes the C # language specification section 7.6.7:7.6.7 This accessA this-access is permitted only in the block of an instanc... | Why does VB not prevent the use of `` Me '' in field initialization like C # does with `` this '' ? |
C_sharp : I have a HashSet < int > and a List < int > ( Hashset has approximately 3 Million items , List has approximately 300k items ) .I currently intersect them usingand I wonder if there is any faster way to do so . Maybe in parallel ? <code> var intersected = hashset.Intersect ( list ) .ToArray ( ) ; | Fast intersection of HashSet < int > and List < int > |
C_sharp : I have a situation where , for testing , I only want my timer method ( FooMethod ) to run one at a time . In the example below , FooMethod is passed as the delegate to a timer . There are many concrete instances of this class . I thought that by making _locker static , only one instance of FooMethod ( ) would... | Monitor.TryEnter with Generic Class |
C_sharp : I have a ten element array of integers . I want to sum the elements by group , so for instance I want to add the value at element 0 with the value at element 1 , then with the value at element 2 , then 3 , and so on through to element 9 , then add the value at element 1 with the value at 2,3 , through to 9 un... | Adding elements of an array |
C_sharp : I am testing my run ( ) function to make sure it has all the correct things populated by the end of the method . I populate 4 fields from our databases , two strings , and two IEnumerable ( string ) 's . The idea is to print them all out for all the people I am pulling from the database.When I only print the ... | Does Console.Write ever fail ? |
C_sharp : ( All of the below are simplified for brevity ) I have a static reference to a processing object.The Processor contains a function to which I can pass an object Package , which is the info to be processed.The Package comes from a list of lots of packages which should be processed . These packages are unqique ... | Will parameter of a static object 's non-static method be shared from multiple threads ? |
C_sharp : I 'm trying to download a composition media file into my hard drive using the following code : But every time I get an exception with this message : `` The remote server returned an error : ( 302 ) FOUND . `` Note that this method is called after Twilio calls my StatusCallback method which I 've set when crea... | C # Twilio retrieve composition media |
C_sharp : I need to analyze some extension method . For example Enumerable.ToList.Code sample to analyze : Diagnostic : However symbolInfo.Symbol is null and there are no any candidates . If I change the code sample like that : then symbolInfo has a candidate but still does n't have Symbol . How to get a symbol info of... | SymbolInfo of extension method |
C_sharp : Currently in my game i want trying to move my object towards both x axis and y axis.As I also wanted to put it into center , I have put a camera.Here is my Camera code-and in Game1.cs file as usual in begin statement i am putting this-Here ba is the object of ball , its just have moving x and y functionalitie... | Need help on monogame screen resolution and intersection |
C_sharp : Hi I see following code : Why using Action and then invoke action here ? Why not just using txtMessage.Text = message to replace the code in function body ? UpdateA fuller version of the code , presented in a comment , reproduced below with syntax highlighting , indentation etc . <code> void UpdateMessage ( s... | Why using Action in this code ? |
C_sharp : I can not understand why the above code ( modified from the actual codes ) always gives me weird result : '' ZXCV ) '' instead of `` Tom ( ZXCV ) '' .Does anybody knows the reason behind and can provide a reference if possible ? <code> StringBuilder htmlResp=new StringBuilder ( ) ; int ? cuID= 1 ; string cuNa... | Why the following Conditional Operator works strangely in StringBuilder containing Nullable type ? in C # ? |
C_sharp : Why does the compiler reject this code with the following error ? ( I am using VS 2017 with C # 7.3 enabled . ) CS0019 Operator '== ' can not be applied to operands of type 'T ' and 'T'The version without generics is of course perfectly valid . <code> public class GenericTest < T > where T : Enum { public boo... | C # Enums and Generics |
C_sharp : Lets forgot about why I need this.Can we create a class with name `` class '' .Below code resulted in compilation error as class is a reserve keyword.so is there any hack or a way to fool C # compiler ? : ) This Question was asked by interviewer in my last interview and he told me it is possible . <code> publ... | Can we create class with name `` class '' ? |
C_sharp : I have a multi layered project with a web API project and a library project . Both projects rely on AutoMapper ( and AutoMapper extensions for Microsoft.Extensions.DependencyInjection ) . Based on thishttps : //docs.automapper.org/en/latest/Dependency-injection.html # asp-net-corein the Startup file I 'm sett... | calling AddAutoMapper once per assembly instead of passing in multiple assemblies ? |
C_sharp : I have the following if condition param.days is a string.This works fine , but if I saythen it does not evaluate correctly at runtime . Both statements are not the same in C # .It does say that the value is null but then C # tries to cast it to a bool which is non-nullable.Why did the C # designers choose to ... | Why is n't this allowed in C # ? |
C_sharp : GoalI have a couple of interfaces and some dlls that provide implementations for these interfaces . I want to load the implementation into a new AppDomain ( so I can unload the dll later ) and instatiate the implementation in the new AppDomain and then use a clientside ( here the default AppDomain ) proxy to ... | Wrapping __TransparentProxy of RemotingProxy in another Proxy throws RemotingException |
C_sharp : UPDATE 10:29 MST on 11/7Oddly enough if I move the attribute out of the ComponentModel folder back into the root of the Common project the code works fine . I ca n't imagine what 's possibly referencing the old namespace after all of the references were refactored for the InflowHealth.Common.ComponentModel na... | TypeLoadException on Attribute in shared assembly |
C_sharp : I 've always used role authorization in my .net application . However , I 'm building a demo app and want to give claims a try . I 've always decorated my controller like this where either an admin or User with full access can be authorized.However , I ca n't accomplish the same with claims . In my startup , ... | Is it possible to have a claims authorization with an OR condition like roles ? |
C_sharp : Firstly I need to get all the data from ODBC ( this is working already ) . Then comes the most complicated part that I am not sure yet how it can be done . There are two tables of data in ODBC . I am merging them with my current code and filtering them with certain parameters.Table 1 in database : Table 2 in ... | Build one datatable out of two with certain conditions |
C_sharp : QUESTION : How do I apply my personal DocumentationProvider to source tree symbols ? Which is the type of symbol i get when i use the SymbolFinder.FindSymbolAtPosition ( ) Specifically I want to override the GetDocumentationForSymbol ( ) function . I have it overridden for my autocomplete symbols but not the ... | Using roslyn for hover over data for source tree symbols |
C_sharp : Possible Duplicate : Why is Func < T > ambiguous with Func < IEnumerable < T > > ? I noticed a very weird overload resolution issue with generics ... Consider the following methods : ( C # 4 , tested in LINQPad ) If I try to call Foo with a lambda expression as the selector , everything works fine : But if I ... | Generics , overload resolution and delegates ( sorry , ca n't find a better title ) |
C_sharp : I 've look in many places including google and SO but I did n't find any relevant answer.I 've made a few changes in my app recently , including updating ZedGraph dll ( from 5.1.4.26270 to 5.1.6.405 ) and since , VS wo n't open my controls throwing this error : Could not load file or assembly 'ZedGraph , Vers... | VS wo n't open control since dll update |
C_sharp : The following code produces a CA2000 ( `` Dispose objects before losing scope '' ) violation for the first line of Main , but not the second . I would really like the CA2000 violation for the second line , because this is a ( obviously simplified ) pattern often found in a large code base I work on . Does any... | Why does FxCop not report CA2000 for this trivial case of not-disposed class instance ? |
C_sharp : For money I am using a custom value type which holds only one decimal field . Simplified code is as follows.While using this struct in my project sometimes an ambiguity arises . And also sometimes I am setting an object with a constant number which is supposed to be a Money . For now I am initializing the obj... | Can I assign a suffix to my custom value type ? |
C_sharp : So I 've got these classes that expose a collection of child objects.I do n't want other classes adding or removing objects from collections because I need to wire into events in the child objects , so as they get added or removed I want to be able to do additional processing . But I really love the ease of m... | Is there a good pattern for exposing a generic collection as readonly ? |
C_sharp : I have a c # class which looks likeFrom a browser , I submitted a JSON object as followsWhere the value 1 assigned to the ParentNode property representes a database identifier . So , in order to bind properly to my model , i need to write a custom JSON converterBecause i get a `` Current JsonReader item is no... | How to bind a given property when deserializing a JSON object in c # Web Api ? |
C_sharp : I would like to run this function under mono ( my current version is 4.0.2 ) But it fails with the error : What is the Mono equivalent of ClientConnectionId ? Or how can I fix it ? <code> public Object GetConnectionProperty ( SqlConnection _conn , string prop ) { if ( _conn.State == ConnectionState.Closed & p... | Mono equivalent of ClientConnectionId |
C_sharp : I have a scenario where a class loads objects of one type , due do abstractions I can not use a generic class ( generics tend to spread like cancer : ) but I often want to work with a generic version of the objects once retrieved , which resulted in code like this ( simplified ) : Where LoadItems returns a Li... | Backdooring Generic Lists through IList |
C_sharp : i am implementing Floyd–Warshall algorithm with c++ , c # and java . in each language i use sequential and parallel implementation after testing the result was : ( Elapsed time is only for main Function and Reading Files , Inti of Variable and ... are not measured . ) download sources here SourceCodesc++IDE :... | Comparing c # , c++ and java performance ( Strange behavior of c # ) |
C_sharp : can I get a hand converting the following into a LINQ statement.Currently I have it down to this : The problem with the LINQ above is that it returns entries that have titles changed . Within the database I keep history of all records ( hence the need for the first on the createdDate order descending . When I... | Convert an SQL statement into LINQ-To-SQL |
C_sharp : I would like to call one method 3 times Using LINQ , the method returns an object , with that object I want to add it into a List , How do i do it ? <code> List < News > lstNews = new List < News > ( ) ; lstNews.Add ( CollectNews ) [ x 3 times ] < -- Using Linq private static News CollectNews ( ) { ... } | Call method x times using linq |
C_sharp : I am getting the following error in an editor template of mine , ApplicantAddressMode : error CS0019 : Operator ' ! = ' can not be applied to operands of type 'Comair.RI.ViewModels.ApplicantAddressType ' and 'Comair.RI.Models.ApplicantTypesOfAddress ' '' } The type Comair.RI.ViewModels.ApplicantAddressType is... | Why am I getting a type mismatch error with a type I can not see anywhere in my solution ? |
C_sharp : I understand why GUI controls have thread affinity.But why do n't the controls use the invoke internally in their methods and properties ? Now you have to do stuff like this just to update TextBox value : While using just textBox.Text = `` newValue '' ; would be enough to represent the same logic . All that w... | Why do n't WinForms/WPF controls use Invoke internally ? |
C_sharp : Have a collection of objects . Schematically : Need : Is it possible to LINQ such ? Note : Ordering is important . So Bs = [ 5 ] ca n't be merged with Bs = [ 1 , 2 ] <code> [ { A = 1 , B = 1 } { A = 1 , B = 2 } { A = 2 , B = 3 } { A = 2 , B = 4 } { A = 1 , B = 5 } { A = 3 , B = 6 } ] [ { A = 1 , Bs = [ 1 , 2 ... | Transform a collection |
C_sharp : I have an object that looks something like this ( obviously simplified ) What I would like is for ETag to be a hash of the json serialization of the object omitting the ETag property ( to prevent a recursive loop ) . However , I can not just use a [ JsonIgnore ] attribute since at other times I want to be abl... | How to serialize all but a specific property in one specific serialization |
C_sharp : How can I wait for n number of pulses ? I want the above thread to wait until being notified n times ( by n different threads or n times by the same thread ) .I believe there is a type of counter to do this , but I ca n't find it . <code> … // do somethingwaiter.WaitForNotifications ( ) ; | Let a thread wait for n number of pulses |
C_sharp : I have written some test code for comparing the performance of using direct property access or reflection or reflection by using delegates . But the results that I get are baffling , since it is showing that reflection is not much slower ( ~4 % ) than direct property access , which I do not believe to be true... | Reflection test does not show expected numbers |
C_sharp : I 'll try to make this as clear as possible . A Plugin architecture using reflection and 2 Attributes and an abstract class : PluginEntryAttribute ( Targets.Assembly , typeof ( MyPlugin ) ) PluginImplAttribute ( Targets.Class , ... ) abstract class Plugin Commands are routed to a plugin via an interface and a... | How to build a dynamic command object ? |
C_sharp : I need to parse DateTime in `` Myy '' format , so : the first number is a month without leading zero ( 1 to 12 ) , andthe second number is a year with two digits.Examples : When using DateTime.ParseExact with `` Myy '' as a format , DateTime throws an exception when month is without leading zero.This code thr... | Parsing DateTime in a `` Myy '' format |
C_sharp : This is more of an academic question about performance than a realistic 'what should I use ' but I 'm curious as I do n't dabble much in IL at all to see what 's constructed and I do n't have a large dataset on hand to profile against.So which is faster : or : Keep in mind that I do n't really want to know th... | Which is faster in a loop : calling a property twice , or storing the property once ? |
C_sharp : We build software that audits fees charged by banks to merchants that accept credit and debit cards . Our customers want us to tell them if the card processor is overcharging them . Per-transaction credit card fees are calculated like this : A `` fee scheme '' is the pair of ( fixed , variable ) used by a gro... | given 10 functions y=a+bx and 1000 's of ( x , y ) data points rounded to ints , how to derive 10 best ( a , b ) tuples ? |
C_sharp : I migrated to a Table Azure Provider for managing Microsoft bot framework state.In my telemetry , I see dependencies call being made to my new Table Azure Storage however I still see a lot of calls being made to state.botframework.com and some have the usual random slow response time . This does not seem norm... | Migrated bot state provider but calls to state.botframework.com are still being made |
C_sharp : I have some kind of a job scheduling implemented which calls a function ProcessJob . Now inside this method I need to generate url to one of my pages i.e DoanloadPage.aspx ? some_params . That url is sent to user via email and when user clicks that link , it will take to the page . The problem here is that I ... | Making relative urls in asp.net webform custom classes without Request |
C_sharp : In this code , is it safe to not await the CopyToAsync or the stream could be disposed before the actual copy is done ? <code> public Task SaveAsync ( Stream source , string filepath ) { using ( var file = File.OpenWrite ( filepath ) ) { return source.CopyToAsync ( file ) ; } } | Is safe to not await inside a using block ? |
C_sharp : I am building an expression of type Expression < Func < Project , bool > > which returns the correct IQueryable < Project > from the database . IQueryable < Project > has a nested collection of SubProjects that I would like to filter as well . It looks something like thisCan this be done with one call to the ... | How can I filter nested items of IQueryable < T > ? |
C_sharp : Do I have to do this to ensure the MemoryStream is disposed of properly ? or is it OK to inline the MemoryStream so that it simply goes out of scope ? Like this ? <code> using ( MemoryStream stream = new MemoryStream ( bytes ) ) using ( XmlReader reader = XmlReader.Create ( stream ) ) { return new XmlDocument... | Can I `` inline '' a variable if it 's IDisposable ? |
C_sharp : I was stepping through .Net Framework source code to find a tricky bug ( HttpApplication.cs ) , and I noticed lines like these in the code ( these are copy/pastes , I did n't edit anything ) : andI 'm wondering if this is obfuscated code , or is this some sort of c # convention I 've never seen before ? VS 20... | Weird variable name ( _ [ ... . ] ) in .Net Source Code ( HttpApplication.cs ) |
C_sharp : While attempting to create a .NET Core class library for PowerShell I 'm seeing some strange differences between .NET Standard and .NET Core.Following this guidance , I 've created a simple .NET Standard 2.0 class library and have been able to successfully load it in PowerShell 5.1 and PowerShell 6.0.1 using ... | Ca n't call/load .NET Core assembly but .NET Standard works fine using Add-Type in PowerShell |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.