text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I have a model which has is below and when I add ComboProducts object with the linq below I am getting the error . Is there something I am missing in this code ? Errorappears in two structurally incompatible initializations within a single LINQ to Entities query . A type can be initialized in two places in th... | Error with two structurally incompatible initializations within a single LINQ |
C_sharp : I am using .Replace ( ) method to replace a placeholder [ CITY ] in arabic language.I get the following output As you can see the city instead of being placed next to ABC is added at the extreme right.This issue happens only for arabic and works fine for other languages ( english/thai/spanish etc ) Not sure w... | C # .Replace ( ) method does not work correctly with Arabic language |
C_sharp : Is there any point in doing this ? ... as supposed to this : Setting aside the obvious null dereference possibility , If I where to write a lot of value types using this method would n't the former be much better because it will have it 's own version of the write method to call , or is it just gon na bloat t... | Boxing , a thing of the past ? |
C_sharp : My question is simple , why GC ca n't figure it out that timer object in the main should be garbage collected along with the timer inside TestTimer and associated EventHandler ? Why am I continously getting console.Writeline output ? <code> class Program { public static void Main ( ) { TestTimer timer = new T... | Why ca n't GC figure it out ? |
C_sharp : I am not a Java programmer . I read the documentation on `` final '' , and understand it to mean `` a variable 's value may be set once and only once . `` I am translating some Java to C # . The code does not execute as expected . I tried to figure out why , and found some uses of final that do n't make sense... | Understanding Java 's `` final '' for translation to C # |
C_sharp : I have this method : What I would like to do is to delete from three tables that are here : Is there a delete function in EF6 that I can use to delete all the rows or should I somehow make a SQL call ? <code> [ Route ( `` Delete '' ) ] public IHttpActionResult Delete ( ) { } public System.Data.Entity.DbSet < ... | How can I delete rows from tables using EF when inside an Asp.Net method ? |
C_sharp : BackgroundI have a couple of utility methods I would like to add to a solution on which I am working and use of dependency injection would open many more potential uses of said methods.I am using C # , .NET 4Here is an example of what I am trying to accomplish ( this is just an example ) : What I have done he... | How do I write a C # method that will accept an injected dependency of unknown type ? |
C_sharp : This is normal LINQ , and this Test succeeds : But when you insert the data into a database and try to do the same when using LINQ to Entities , it seems like the resulting SQL is the same , regardless of the sorting you apply.Can somebody please help me ? - > Please show me how to keep my sorting when groupi... | LINQ versus LINQ to Entities , keep Sorting when Grouping |
C_sharp : I 'm using Entity Framework 4 along with MSSQL to store and access data on my Windows Forms application.Here is an example class I use to access data : And here 's an example of how I use it.Someone suggested that I use IDisposable to properly `` clean up '' the connection , but I do n't know how to implement... | How would I implement IDisposable in this context ? |
C_sharp : Is it possible to write the folowing using lambda ( C # ) <code> private static void GetRecordList ( List < CustomerInfo > lstCustinfo ) { for ( int i = 1 ; i < = 5 ; i++ ) { if ( i % 2 == 0 ) lstCustinfo.Add ( new CustomerInfo { CountryCode = `` USA '' , CustomerAddress = `` US Address '' + i.ToString ( ) , ... | Rewriting a statement using LINQ ( C # ) |
C_sharp : I have an abstract Model and an implementationMy coins object does not show `` Coins '' as its label in my view when I use Html.LabelFor on it , it shows `` Label '' . If I move the DisplayName attribute into Treasure , it works ... but I need to be able to change the label for different implementations of th... | MVC Attributes on abstract properties |
C_sharp : Since I do n't have much reputation to post image , I am elaborating as a big question.I have three windows forms in which the execution of events get increased each time the form is created.1 . Form1 ( MainForm ) Here I call the second form ( SubForm ) which contains a user control . 2 . Form2 ( SubForm ) He... | How do I restrict events firing more than once at a time |
C_sharp : I have a XML file that contains multiple < p > tags in it . Some of the < p > tags contain < br/ > in it . So , I am supposed to create a new XElement for each < br/ > in the tag . I have tried to achieve by reading each line using foreach and replacing each < br/ > with < /p > + Environment.NewLine + < p > .... | How do I replace multiple < br/ > tags with a specific element in a new line ? |
C_sharp : I 've encounter a weird problem with C # threading.This is my sample program using thread to `` activate '' the Print ( ) function at each agent in the agentList.And here is the result when I run the above program : But what I expected is something contains all 4 agents likeThe most amazing thing is that if I... | Weird Threading with C # |
C_sharp : I 've noticed a difference in the way the C # 8.0 compiler builds closure classes for captured IDisposable variables that are declared with a C # 8.0 using declaration , as opposed to variables declared with the classic using statement.Consider this simple class : And this sample code : The compiler generates... | Why are closures different for variables from C # 8.0 using declarations ? |
C_sharp : Given the following program : Which produces the following output : I chose to use dynamic here to avoid the following : using switch/if/else statements e.g . switch ( foo.GetType ( ) .Name ) explicit type checking statements e.g . foo is Foo1explicit casting statements e.g . ( Foo1 ) fooBecause of the dynami... | Using dynamic to set disparate properties of uncontrolled ( third party ) sealed types |
C_sharp : I 've got a class with readonly fields that indicate the state of my object . These fields should be visible from the outside.At first I showed these fields with properties like this : But as this is readonly , users of my class ca n't change the instance of the state . Therefore , I removed my property , set... | Can readonly fields be public ? |
C_sharp : Consider the following : I am able fill dictionary manually . However is it possible add it dynamically ? How I may convert generic method to Func ? <code> public interface ISomething { string Something ( ) ; } public class A : ISomething { public string Something ( ) { return `` A '' ; } } public class B : I... | How to populate dictionary of Func < T > dynamically |
C_sharp : I 'm converting a project from Java to C # . I 've tried to search this , but all I come across is questions about enums . There is a Hashtable htPlaylist , and the loop uses Enumeration to go through the keys . How would I convert this code to C # , but using a Dictionary instead of a Hashtable ? <code> // M... | Converting Enumeration < Integer > for loop from Java to C # ? What exactly is an Enumeration < Integer > in C # ? |
C_sharp : I have a small issue with visual studio.I have a method that throws a CustomExceptionIf I wrap the code that calls this method in a try/catch I can see the exception details in the debuggerif I remove the try/catch I can see that the `` errors '' property has Count=4 but I can not see the errors ... Is this e... | View Detail window does not expand Collection properties |
C_sharp : I 'm trying to create a program that parses data from game 's chat log . So far I have managed to get the program to work and parse the data that I want but my problem is that the program is getting slower.Currently it takes 5 seconds to parse a 10MB text file and I noticed it drops down to 3 seconds if I add... | Regular Expressions slowing down the program |
C_sharp : I have array of strings and I have to add hyperlink to every single match of item in array and given string.Principally something like in Wikipedia.Something like : string p = `` The Domesday Book records the manor of Greenwich as held by Bishop Odo of Bayeux ; his lands were seized by the crown in 1082 . A r... | How to make programmatically html text with hyperlinks like in Wikipedia ? |
C_sharp : This is the example : but it says acnnot convert Anonymous type # 1 to FotoLiveLove . <code> public class FotoLiveLove { public string Tipologia { get ; set ; } public string URL { get ; set ; } } IList < FotoLiveLove > fotoLiveLove = xDoc [ `` statuses '' ] .Select ( x = > new { Tipologia = `` twitter '' , U... | Can I populate a list of my own class directly in LINQ ? |
C_sharp : Is there a way to specify that a generic type be of one type or another type ? <code> public class SoftDrink < T > where T : TypeOne or TypeTwo { } | Specify a C # Generic Constraint to be of ClassA OR ClassB ? |
C_sharp : I take user input on a form and bind it to a parameter which will then tie to my report . Can I use a single collection to hold all of my parameters ? It seems redundant to have to create a collection and a parameter for every item I want to pass to my report . To make this work the way I require , I 've had ... | Use a single collection to hold all parameters |
C_sharp : I have some client code that sends date in the following format `` 1/31/2013 11:34:28 AM '' ; I am trying to cast it into DateTime objectthis throws String was not recognized as a valid DateTime.how can i cast it ? <code> string dateRequest = `` 1/31/2013 11:34:28 AM '' ; DateTime dateTime = DateTime.Parse ( ... | DateTime.Parse throws exception when parsing string |
C_sharp : The following program will print the fields and whether the are constant or not using IsLiteralIt works correctly for all types , except for decimal is will return false.Can anyone explain this behavior ? And is there a better way to see if a field is constant ? <code> public static class Program { public sta... | Why does IsLiteral return false for decimal ? |
C_sharp : I work with multethreading bug . Now I see that for some reason lock is n't executed even once but is locked . I have the next class : I paused all threads in the VS , inspected all of them and see that there is only one thread in the SomeMethod and it is waiting for lock ( _lock ) to be freed ( _inCnt = 0 ) ... | Corrupted lock ? Magic deadlock ? |
C_sharp : I 'm aware of technique to handle IDisposable in a traditional manner . Say , in OnStop ( ) method of windows service I close message queue client : For the first time today I saw one guy doing that this way : What is exactly happening inside his `` using '' or does he dispose correctly at all ? <code> if ( c... | Disposing by setting to null ? |
C_sharp : I 've an XML file such as below : For some reasons , I need to create child and nested nodes from the Element node attributes.The output that I want is : How can i do it ? Or any idea , reference , article ... Thanks . <code> < ? xml version= '' 1.0 '' encoding= '' utf-8 '' ? > < LayoutControl ID= '' rootlyt ... | Convert inline XML node to nested nodes in asp.net using c # |
C_sharp : I 'm just curious how .NET defines a process architectural interface if I compile the source code under `` Any CPU '' configuration setting . I always thought that if you run that process in a x64 computer , it will be a 64-bit process . However , the example below shows a totally different thing.I have a sim... | How does .NET define a process architectural interface ? |
C_sharp : I 'm working on modifying Roslyn , and in this file I come across this code : Following the reference to specializedMethodReference.UnspecializedVersion gets me to this file , and this code : I 've read those comments three times , and I 've done a bit of Googling , and I have no idea what they 're talking ab... | What are specialized events , fields , methods and properties ? |
C_sharp : I must be reinventing the wheel here - but I 've searched and I ca n't find anything quite the same ... Here 's my code for creating a sequence of zero or more objects that have a default constructor : My question is quite simple : Is there a Linq equivalent of this I should be using ? <code> public static IE... | Linq method for creating a sequence of separate objects ? |
C_sharp : In the following C # snippet I override the == method . _type is a number of type short . So I 'm actually saying that two WorkUnitTypes are the same when those two shorts are the same.Because R # warns me , and it is totally clear why , that type1/type2 could potentially be null I 'm trying to catch that wit... | Check for null in == override |
C_sharp : BackgroundI have a convenience class which is essentially a dictionary that holds a tag/value pair list for submission to an API.At its very basic level all I did is this : This maps well to the needs of the API , since the whole thing gets sent and parsed as a string . However , it 's not so great for the ca... | Use object initializer syntax with an interface |
C_sharp : This only happens on a Windows 8.1+ touch device . I have some panels where the user can slide around with their finger . I have implemented PreFilterMessage so that I can catch the mouse move globally throughout the application without having to worry about child controls interfering.I sometimes receive the ... | How can a mouse event sender be null ? ( Only on Windows 8.1+ TOUCH ) |
C_sharp : I understand that async which awaits a task yields execution back to the caller , allowing it to continue until it needs the result.My interpretation of what I thought would come out of this was correct up until a certain point . It looks as though there 's some sort of interleaving going on . I expected Do3 ... | Can exiting an async method yield control back to a different async method ? |
C_sharp : Today I have taken a look at the implementation of the Thumb control in order to learn how it works . What struck me is , that there are 3 methods which seem to override internal virtual parent methods , namelyI am not so much interested in what these methods do specifically , but rather what could be valid r... | Why do WPF shipped classes have internal virtual methods ? |
C_sharp : My code : At times my application will stop at the cpuLabel invoke and throw an `` ArgumentOutOfRangeException '' when it was handled and fixed in my code . I tried increasing the timer that activates the thread that activates CPUStats ( ) , but to no avail . Why would this happen ? <code> public void CPUStat... | Exception that is handled is still thrown ? |
C_sharp : If I have an event like this : And adds an eventhandler like this : ... is it then possible to register this somehow ? In other words - is it possible to have something like : <code> public delegate void MyEventHandler ( object sender , EventArgs e ) ; public event MyEventHandler MyEvent ; MyEvent += MyEventH... | Is it possible to subscribe to event subscriptions in C # ? |
C_sharp : Hi I am developing a chatbot on amazon lex and I want to send a response card using the lambda function but on using response card function inside the close response format it gives the error of null exception . Can anyone tell the solution to it ? PS I am using FlowerOrder blueprint created by Nikki.Exceptio... | How to send a response card using AWS Lambda in C # |
C_sharp : I want to open the folder where a file had been just saved and select the file , for that I use this little code : It works perfectly.I need to put this code in several places so I decided to create a method , there is also a condition in this method : This does n't work as expected : this opens the parent fo... | Open folder issue |
C_sharp : This might be lame , but here : Now I want to create an instance of the ImplementedInterface and initialize it 's members.Can this be done somehow like this ( using initialization lists ) or the same behavior can only be achieved using the constructor with Double argument ? <code> public interface Interface <... | C # initialization question |
C_sharp : I have the following class : I have a method that takes in Person and a String as parameters : Since Person was passed by reference , it should change the Name of the passed instance . But is this method more readable than the one above ? <code> public class Person { public String Name { get ; set ; } } publi... | Pass by reference : Which is more readable/right ? |
C_sharp : I have created a new VS 2010 extensibility package . So far , all I want to do is have the user press a button and fill a listview with the entire contents of the solution . I have the following code : This does seem to work , however , it populates the list with the contents of the solution with the package ... | Visual Studio Extensibility Package not looking at correct project |
C_sharp : I am a little confused on content equality in reference types specifically . I am not overriding Equality in either case - so why is the behavior different . See 2 simple code examples : Example 1 : Returns TrueExample 2 : Both statements return False <code> class Program { static void Main ( string [ ] args ... | Equality in Reference Types |
C_sharp : My class structure ( simplified ) Now , having only the type FinalClass1 and FinalClass2 I need to get their respective T types from the Foo interface - SomeClass for FinalClass1 and SomeOtherClass for FinalClass2 . The abstract classes can implement more generic interfaces , but always only one Foo.How can I... | Generic type from base interface |
C_sharp : I am wanting to find out if there is a way to initialize a List < T > where T is an object much like a simple collection gets initialized ? Simple Collection Initializer : Object Collection Initilizer : The question is , how and if you can do something like this ? <code> List < int > digits = new List < int >... | Object Initializer for object collections |
C_sharp : Hi , I have the following code which produces a strange behaviour.A property of an instance of objects contained in an IEnumerable produced by linq to Objects , does not get updated in subsequent foreach statements . The foreach statement should enuemerate the IEnumerable . Instead the solution is to enumerat... | Strange behaviour in linq c # under delayed execution |
C_sharp : I am generating two sets of repeating events in seperate loop iterations but am having a conflict when comparing the generated results for conflicts . This seems to be when the times go backwards and I am unsure how to solve this ? The first repeat event will : repeat everyday at 00:00 to 01:00 in `` Europe/S... | How to handle when timezone goes backwards in the future |
C_sharp : For some weird reason , both the System.Runtime.Remoting.Messaging.CallContext and AsyncLocal classes are only available using the full CLR . This makes it really hard to do asynchronous scoping while working with Portable Class Libraries or Windows Phone applications , especially since Windows Phone APIs are... | Implementing asynchronous scoping in PCL and Windows Phone applications |
C_sharp : Sometimes it 's useful to have something like : because X describes both what the type is ( as a class name ) , and the value being accessed/mutated ( as the property name ) . So far so good . Suppose you wanted to do the same thing , but in a generic way : For this example , the compiler complains that : The... | Why is there a name clash between generic type parameter and other members |
C_sharp : Consider the following code ... In my tests for a RELEASE ( not debug ! ) x86 build on a Windows 7 x64 PC ( Intel i7 3GHz ) I obtained the following results : It seems that using a Func < > to define a delegate to create new objects is more than 6 times faster than calling `` new T ( ) '' directly . I find th... | Why is using a Func < > so much faster than using the new ( ) constraint on a generic sequence creator |
C_sharp : We have our own certificate that we use as part of the ClientCredentials in Transport Client Credentials as seen below.Our partner also provided us with a copy of their certificate that is used on the server in order to validate their server . Calls to the service currently succeed without us having installed... | What role does a public certificate play in WCF ? |
C_sharp : I want to create a TCP Listener using Kestrel and the System.IO.Pipelines package . The messages I receive will always be HL7 messages . An example message could beMSH|^~ & |MegaReg|XYZHospC|SuperOE|XYZImgCtr|20060529090131-0500||ADT^A01^ADT_A01|01052901|P|2.5EVN||200605290901||||200605290900PID|||56782445^^^... | How to create a responding TCP listener with the System.IO.Pipelines package ? |
C_sharp : I have two bytes . I need to turn them into two integers where the first 12 bits make one int and the last 4 make the other . I figure i can & & the 2nd byte with 0x0f to get the 4 bits , but I 'm not sure how to make that into a byte with the correct sign.update : just to clarify I have 2 bytesand I need to ... | Perform signed arithmetic on numbers defined as bit ranges of unsigned bytes |
C_sharp : I really do n't understand why c # compiler allows some useless statements but disallows some other useless statements . <code> static void Main ( ) { string ( ' a ' , 1 ) ; // useless but allowed // '' a '' ; // useless and disallowed new int ( ) ; // useless but allowed //0 ; // useless and disallowed new c... | Why are some useless statements partially allowed ? |
C_sharp : I 'm using Unity to make a game . I have multiple animal enemies in the game.I 'm working on missions inside the game that you have to kill a random number of random animals , this I already have.What I have a problem with is to increase the mission count when you kill an animal.I got a script ( dead ) sittin... | How can I simplify this long series of if statements ? |
C_sharp : I 'm trying to assign a static List < PropertyInfo > of all DbSet properties in the Entities class.However when the code runs the List is empty because .Where ( x = > x.PropertyType == typeof ( DbSet ) ) always returns false.I tried multiple variations in the .Where ( ... ) method like typeof ( DbSet < > ) , ... | Linq .Where ( type = typeof ( xxx ) ) comparison is always false |
C_sharp : I 'm working on a VS Extension that needs to be aware of which class member the text-cursor is currently located in ( methods , properties , etc ) . It also needs an awareness of the parents ( e.g . class , nested classes , etc ) . It needs to know the type , name , and line number of the member or class . Wh... | VS Extension : TextPoint.GreaterThan / LessThan very slow for large files |
C_sharp : I am trying to Pinvoke the lmdif1 method in the cminpack_dll.dll from c # and i am running into some curious errors . The 2nd and third parameters passed to lmdif1 are ints , and for my test the values in order are 12 and 9 . Now when ther are in the C code , the value that was 12 is now 9 and the value that ... | PInvoke lmdif1 signature |
C_sharp : I need to integrate an ASP.NET MVC website with a 3rd party COM application . The code looks something like this : The problem is that after a while I start getting COMExceptions most probably because I never close that context using obj.ReleaseApplicationContext ( ) . So I 'm thinking about writing a wrapper... | COM and thread safety |
C_sharp : I have been working on a Windows 8.1 RT app where the user loads an image with Stretch=Uniform . The image can be as small as possible and as big as possible.The clipping happens in my user control and my user control appears when I tap/press and hold on the screen/image.Clipping happens when when I tap and h... | Clipping a low resolution image using Transforms and assigning it to my user control |
C_sharp : In python I have the following : this is a structure to represent a graph and that I find nice because its structure is the same as the one of one of it 's nodes so I can use it directly to initiate a search ( as in depth-first ) . The printed version of it is : And it can be used like : Now , I 'm curious to... | Creating in c # , c++ and java a strong typed version of a python weak typed structure |
C_sharp : I have a Xamarin.Forms app that implements certificate pinning utilizing the ServicePointManager.ServerCertificateValidationCallback class and method . On Android and iOS , this works without issue in that it will allow connections to expected services whose certificate keys have been pinned and disallow conn... | UWP ServicePointManager.ServerCertificateValidationCallback |
C_sharp : Is there any way of being notified when something subscribes to an event in my class , or do I need to wrap subscription/unsubsription in methods eg : instead ofThe reason I ask is because the event is already exposed directly on a ISomeInterface but this particular implementation needs to know when stuff sub... | Any way to be notified when something subscribes to an event / delegate ? |
C_sharp : The following code compiles : because defau1t is interpreted as a goto label . However in the following case : the compiler correctly identifies the mistake : error CS1525 : Unexpected symbol defau1t ' , expecting } ' , case ' , ordefault : 'Why is that ? What 's the reason of allowing arbitrary labels inside... | What 's the reason of allowing arbitrary labels inside the switch statements ? |
C_sharp : I want to create a generic class where the type of the class can Parse strings.I want to use this class for any class that has a static function Parse ( string ) , like System.Int32 , System.Double , but also for classes like System.Guid . They all have a static Parse functionSo my class needs a where clause ... | Generic class where type can Parse strings |
C_sharp : I 'm trying to find a good way to cumulatively apply up to 5 Func 's to the same IEnumerable . Here is what I came up with : I thought that it would apply these in a cumulative fashion , however , I can see from the results that it 's actually just applying the last one ( DepartmentFilter ) .There are 2^4 pos... | Need to & & together an indeterminate number of Func < TEntity , bool > |
C_sharp : My task is simple : I have a CSV file inside a C # string , split with semicolons . I need to add spaces for each empty cell . A ; B ; ; ; ; C ; should become A ; B ; ; ; ; C ; . Right now , I 'm using the replace method twice : That 's necessary , because in the first pass , it will replace any occurance of ... | Better way to add spaces between double semicolons |
C_sharp : There is a confusion in the arrangement of codes and the place where it pleases so I hope to find an explanation for the following : When I have a server `` https : //localhost:48009/ '' and the application is equipped with all the requirements of Signal-R and also Hub exists on it.in folder Hubs There is a H... | How to bring Hub content from Any server to *another server* project Hub ? |
C_sharp : I 'm working through some computer science exercises and I 'm embarrassed to say I do n't know how to console print the above stated code in VS Studio . I 've tried over a number of days , and part of my problem is that I do n't actually know the name of the above mentioned construction ( figuratively speakin... | How to Console.Writeline IEnumerable < ( int a , int b , int c ) > ? |
C_sharp : Is any difference between : And ? What are the benefits of use the first one method ? <code> public void Method1 < T > ( class1 c , T obj ) where T : Imyinterface public void Method2 ( class1 c , Imyinterface obj ) | interface as argument or generic method with where - what is the difference ? |
C_sharp : I am learning the reflections concepts in c # . I have a class like this In another class I would like to extract the values from the list . I have stupid ways to do it likeThe operations in the foreach loops are similar . How can I do this in a clear way by using reflections ? <code> public class pdfClass { ... | Simple question : Reflections in C # |
C_sharp : style that I have to create in code-behind . It has a checkbox that looks like this..How I do in code-behind ? <code> < GridView > < GridViewColumn Width= '' 30 '' > < GridViewColumn.CellTemplate > < DataTemplate > < StackPanel > < CheckBox/ > < /StackPanel > < /DataTemplate > < /GridViewColumn.CellTemplate >... | WPF How to set checkbox in Gridview binding in code behind |
C_sharp : I have a consumer class responsible for consuming a string and deciding what to do with it . It can either parse and insert the parse data in a database or notify an administrator . Below is my implementation.Below is my unit test.Is it code smell to mix mocks and real implementation in unit tests ? Also , ho... | Is it a test smell to mix in real implementation and mocks ? |
C_sharp : After some resent tests I have found my implementation can not handle very much recursion . Although after I ran a few tests in Firefox I found that this may be more common than I originally thought . I believe the basic problem is that my implementation requires 3 calls to make a function call . The first ca... | How can I improve the recursion capabilities of my ECMAScript implementation ? |
C_sharp : For ExampleTo something like <code> txtUnitTotalQty.Text = `` '' ; txtPrice.Text = `` '' ; txtUnitPrice.Text = `` '' ; lblTotalvalue.Text = `` '' ; ( txtUnitTotalQty , txtPrice , txtUnitPrice , lblTotalvalue ) .Text = `` '' ; | Can I run multiple control but same method in C # |
C_sharp : I tried the following code : This code work fine and result will contain -2 ( I know why ) .But when doing this : This will not compile because of overflow problem.Why ? <code> int x , y ; x = y = int.MaxValue ; int result = x + y ; const int x = int.MaxValue ; const int y = int.MaxValue ; int result = x + y ... | Overflow error when doing arithmetic operations with constants |
C_sharp : I have a class , which holds some details in a large data structure , accepts an algorithm to perform some calculations on it , has methods to validate inputs to the data structure . But then I would like to return the data structure , so that it can be transformed into various output forms ( string / C # Dat... | OO Design - Exposing implementation details through an interface |
C_sharp : Whats the difference between these three ways of creating a new List < string > in C # ? <code> A = new List < string > ( ) ; B = new List < string > { } ; C = new List < string > ( ) { } ; | Whats the difference between these three ways of creating a new List < string > in C # ? |
C_sharp : Okay - I 'm not even sure that the term is right - and I 'm sure there is bound to be a term for this - but I 'll do my best to explain . This is not quite a cross product here , and the order of the results are absolutely crucial.Given : Where each inner enumerable represents an instruction to produce a set ... | Calculate a set of concatenated sets of n sets |
C_sharp : Is there a way to lock or freeze a part of code against formatting in Visual Studio ? I want to protect the following code : to be formatted as : but still be able to format the rest of the document . <code> Method ( `` This is a long text '' , 12 , true ) ; Method ( `` Hi '' , 558 , true ) ; Method ( `` Shor... | Freeze part of code against formatting |
C_sharp : So I am recently writing a relatively complex application written in C # that performs an array of small tasks repeatedly . When I first started the application I realized that a lot of the code I was typing was repetitive and so I began encapsulating the majority of the app 's logic into separate helper clas... | Where is the correct the place to handle exceptions in my C # applications ? |
C_sharp : The instructions : Please write a piece of code that takes as an input a list in which each element is another list containing an unknown type and which returns a list of all possible lists that can be obtained by taking one element from each of the input lists . For example : [ [ 1 , 2 ] , [ 3 , 4 ] ] , shou... | Generate permutations using polymorphic method |
C_sharp : I mostly develop using C # , but I think this question might be suitable for other languages as well.Also , it seems like there is a lot of code here but the question is very simple.Inlining , as I understand it , is the compiler ( in the case of C # the Virtual Machine ) replacing a method call by inserting ... | How does a method with an absolute return path gets inlined ? |
C_sharp : If I create an extension method on Enum called HasFlag , whenever I try to call HasFlag on an enum instance , it uses the extension method , rather than the instance method . Why ? With code : Compiles to : Why does n't the compiler use the Enum.HasFlag instance method ? <code> public static class Extensions ... | Why does HasFlag extension method on Enum trump Enum.HasFlag ? |
C_sharp : I 'm looking for something similar to what would have a signature like this : This needs to avoid potential race conditions across threads , processes , and even other machines accessing the same filesystem , without requiring the current user to have any more permissions than they would need for File.Create ... | How do I try to create a file , and return a value indicating whether it was created or not ? |
C_sharp : I am confused about what I need to do in order to correctly `` set up '' my unverifiable method so that it conforms to code access security guidelines.Given the following methodwhich is deemed unverifiable by PEVerify , what attributes do I absolutely need to apply to the method definition ? [ SecurityCritica... | Confusion regarding code access security with unverifiable code |
C_sharp : I want to test if an xml attribute is present . Given this : This first test works : '' GetNamedItem '' is supposed to return null , but the following test throws an exception complaining about the null it returns.Why the difference ? Just curious . <code> XmlAttributeCollection PG_attrColl = SomeNodeorAnothe... | Why can one null return be tested but another throws an exception ? |
C_sharp : There 's a lot of code like this in company 's application I 'm working at : From my understanding of Lazy this is totally meaningless , but I 'm new at the company and I do n't want to argue without reason.So - does this code have any sense ? <code> var something = new Lazy < ISomething > ( ( ) = > ( ISometh... | C # Using Lazy.Value right after its declaration |
C_sharp : I have a use case in Q # where I have qubit register qs and need to apply the CNOT gate on every qubit except the first one , using the first one as control . Using a for loop I can do it as follows : Now , I wanted to give it a more functional flavor and tried instead to do something like : The Q # compiler ... | Can I use lambda in Q # to operate on qubits ? |
C_sharp : The .Net Equals ( ) returns different results , though we are comparing the same values . Can someone explain me why that is the case ? Has it got to do anything with the range of the types we are comparing against ? <code> class Program { static void Main ( string [ ] args ) { Int16 a = 1 ; Int32 b = 1 ; var... | Why does Int32.Equals ( Int16 ) return true where the reverse does n't ? |
C_sharp : I had an interesting interview question the other day , which I really struggled with . The ( highly ambitious ) spec required me to write , in C # , parsers for two different data streams . Here is a made-up example of the first stream : where 30 is the currency pair , 35 is the number of tenors , and 50,51,... | Processing a data feed format |
C_sharp : I 've got a list of 369 different names and I want to print these names into a csv file . All 's going well until I take a look at the outputted csv file and it only has 251 rows . I 've tried outputting to a .txt instead , and still it only outputs 251 rows . Ive stepped through with the debugger and it is s... | Why does my C # program only write 251 rows to a file ? |
C_sharp : I am trying to add collection initializing to my class . I read about the initializers here : https : //msdn.microsoft.com/en-us/library/bb384062.aspx # Anchor_2I 'll quote the important part that puzzles me : Collection initializers let you specify one or more element initializers when you initialize a colle... | Using collection initializer on my own class |
C_sharp : Why is it necessary in .NET Web API to have a a method that reads the content of an HTTP response asynchronously , given that there is already a method to make the request asynchronously ? Said another way , if I am using HttpClient.GetAsync ( or PostAsync , or PutAsync , etc ) , is the code really any more a... | Why await both the asynchronous request and the reading of its contents ? |
C_sharp : I recently had a program fail in a production server because the server was missing a time zone , so the following line threw an exception : I fixed it exporting the time zone registry branch from a test server , importing it to the production server.My question is , is it possible to install time zones selec... | Is it possible to install time zones on a server ? |
C_sharp : I 've been refactoring a common pattern in my project and found it 's not as simple as using a LINQ Select to an async function.For context , here is how it is done currently.Now if I try to replace the ForEach loop section using LINQ : It complains Type arguments can not be inferred by the usage which leads ... | Better way to Select to an async Func ? |
C_sharp : Let 's say I have : And containers of these two types of animals : Is there a way to cast 'lions ' and 'boars ' so that I can pass them into a function like this ? <code> public class Animal { virtual public void Attack ( ) { } ; } public class Lion : Animal { public override void Attack ( ) { base.Attack ( )... | How do you cast a dictionary < int , child > to dictionary < int , parent > ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.