text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : Uncommenting the marked line below will cause a stackoverflow , because the overload resolution is favoring the second method . But inside the loop in the second method , the code path takes the first overload.What 's going on here ? <code> private static void Main ( string [ ] args ) { var items = new Object... | C # : Why does passing null take the overload with Object [ ] ( but only in some cases ) ? |
C_sharp : I 'm trying to access the user Id from the token but everything I try returns null . The generated token has the necessary information so I do n't think it 's the token generation.This is the part creates the tokenWhen I decode the generated token I can see all of the claims in the token but I ca n't access i... | JWT Token Accessing AuthenticatedUser |
C_sharp : I would like to write the following methodWhere T must be a generic type that takes TItem as its generic info.Call example would be like : Edit : In my case I would only need to for collections.The actual use case is that I wanted to write a method that adds something to a ICollection sadly the ICollection do... | How to make a generic method that take a generic type |
C_sharp : I am getting data from database in following way : Now , I am try to achieve this by using sql queries : But get the following error : The data reader has more than one field . Multiple fields are not valid for EDM primitive or enumeration typesIs it possible to use complex queries like above ? I use EF 6.0 .... | Using sql queries in EF |
C_sharp : I have the following abstract base class : And then I go ahead and implement that class : Compile ... and it works ! Is this advised or does it lead to `` evil '' code ? Is `` params '' sort of syntactic sugar ? <code> public abstract class HashBase { public abstract byte [ ] Hash ( byte [ ] value ) ; } publi... | C # params on method signature does n't break an override / implementation |
C_sharp : I have defined the following classes.Document.csDocumentOrder.csWhen serializing this to an XML I get : But I would like to have it like that , i.e . be the Document elements to be children of DocumentOrder.How can I do that ? <code> public class Document { // ... [ XmlAttribute ] public string Status { get ;... | Serializing List < > with XmlSerializer |
C_sharp : A student of mine had a cool result which I just could n't explain.In her code , she wants to create random circles ( in WPF ) with Random colors . She made the typical beginner 's mistake of creating more than one Random generator , but bear with me , please.This is the code : This will always generate the s... | Explanation for interesting phenomenom with Random ( ) and colors |
C_sharp : How can I do it ? I followed this tutorial , so I have this method : It gives an error : Can not apply operator > = to operands of type string and string <code> if ( getOSInfo ( ) > = `` 7 '' ) { MessageBox.Show ( `` Your Microsoft Windows version is n't supported.\n\nPlease use Windows 7 or above to be able ... | Exit if Windows version is less than 7 |
C_sharp : I have a List of strings where each item is a free text describing a skill , so looks kinda like this : And I want to keep a user score for these free texts . So for now , I use conditions : Suppose In the furure I want to use a dictionary for the score mapping , such as : What would be a good way to cross be... | Searching for dictionary keys contained in a string array |
C_sharp : I 'm trying to figure out a way for a derived class to be made up of members that have more specific types than those specified in the abstract base class . Here is some code that works which does what I want , but does not follow the stipulations I mention . As a result , the client code ( in Main ) must use... | How can one achieve the effect of overriding a base member with more specific type ? |
C_sharp : c # lets you override `` operator true '' and `` operator false '' for a class : and it sort of works . You can sayBut you ca n't sayIn every case the compiler complains.Does the c # compiler use `` operator true '' and `` operator false '' anywhere except for those very specific syntaxes ? EDITI found one mo... | Does `` operator true '' in c # have exactly two places it can be used ? |
C_sharp : I 'm creating a plugin system for my application and I would like for the plugins to expose a humanly readable name . The application will show a list of available plugins , in this list the name need to be available.I want to make it very clear for the developers of the plugins what they need to do to make t... | Giving a plugin-class a humanly readable name |
C_sharp : I 'm having my Web Application which hosts Webservices ( svc ) which are used in a Silverlight Webapplication . After a while I added some new stuff to my Service and now I tried to refresh my proxy classes in the Silverlight Application Project.Unfortunately , Visual Studio now generates new class names.Befo... | service reference proxy class renamed |
C_sharp : I have inherited code that looks like this : Stored Procedure UpdateSomeStuffThis sp is called by ADO.NET in c # like thisI am just asking myself : Is the part IF @ @ Error > 0 Goto ERR good for anything ? If an error happens the sp would return anyway and an exception would be caught in the calling method.Th... | TSQL performance with @ @ Error and Can they be replaced ? |
C_sharp : I need to validate values that can have one of two formats and am trying to do so with a single regular expression but ca n't figure out why it does n't work.The first format is exactly 17 alphanumeric characters and the expression ^ [ A-Za-z0-9 ] { 17 } $ correctly matches the test value 5UXWX7C56BA123456 bu... | How to match entire string to be one of two formats with a single regular expression ? |
C_sharp : The use case that I 'm trying to solve is encapsulation of our domain models . For example , we have internal models that are utilized in a back-end processing that we do not want exposed to clients . One of the main reasons for this encapsulation is volatility of change as our domain objects may change more ... | Is there a way to force WebAPI to strictly conform to a published interface ? |
C_sharp : I 'm just wondering why this codeboth returns 03 31 2016 instead of 03/31/2016 . <code> DateTime.Now.ToString ( `` MM/dd/yyyy '' ) ; and String.Format ( `` { 0 : MM/dd/yyyy } '' , DateTime.Now ) ; | String Format returns unexpected result |
C_sharp : If I do this : My result is : I 'm expecting it to beI 'm trying to replace `` t '' with `` \t '' using regex.replace . I made this example very basic to explain what I 'm trying to accomplish . <code> Regex.Replace ( `` unlocktheinbox.com '' , `` [ t ] '' , `` \\ $ & '' ) ; `` unlock\\theinbox.com '' `` unlo... | How do you replace a single character with a backslash using regex.replace in c # |
C_sharp : So I have this class : The code pretty much explains itself . I tried to solve that and came up with this : I havent tested it out though , but am I doing it right ? Is there better way to do that ? <code> class Test { private int field1 ; private int field2 ; public Test ( ) { field1 = // some code that need... | How to make clone of class instance ? |
C_sharp : I have two tables as in the snapshot below. ! [ Diagram ] [ 1 ] Scenario : A question should have only one correct answer , but can have many ( 3 in my case ) wrong answers ( like a quiz show ) .Problem : Questions table has multiple answers in the Answers table , but only one correct answer . The correct ans... | How to change this many to one relationship to one to one ? |
C_sharp : I have a small menu which I would like to order by the DB table id like the following : Example : The problem with my for each is that when the id changed the ordering not works.Has someone a idea how to order by parentid , previousid and next id which check every time all ids for the relationship ? <code> pu... | Order menu nodes by parent , previous and next id |
C_sharp : In one of my libraries , I have code that returns a MethodInfo from an expression : I had a series of helper functions to enable calls like the following : This would enable the following syntax : This worked great , until I recently upgraded the library to .Net 4.6.1 and the latest c # compiler.In the previo... | Why do different versions of .net ( or the compiler ) generate different expression trees for the same expression |
C_sharp : I am uneasy about the way I have designed a simple program.There is a FileParser object which has OnFileOpened , OnLineParsed , and OnFileClosed events , and several objects which create smaller files based on the content of the file which the FileParser parses.The objects observing the FileParser register th... | Idiomatic C # for object only interacting though having registered to events |
C_sharp : I am working on a project based on WPF , C # and MVVM . Its basically a networking device configurable application via telnet.I have a following output in my wpf textbox and I want to extract MAC Address column values.I think i can not use regex because i dont have anything to match.Any help and suggestions w... | How to extract matching string from large text ? |
C_sharp : I have two SQL statements in my C # code to retrieve some values . I know they are open to SQL injection since I 'm not using parameters , but I 'm not sure if I 'm implementing them correctly . ( Note : each of these are in loops that are looping through rows of a data table ) First example : In the above st... | Properly securing SQL statement with parameters |
C_sharp : The Best practices for exceptions document on MSDN says that you can have an exception builder method inside your class if the same exception is to be used in many parts of the class . But also , it says that in some cases , it 's better to use the exception 's constructor.Let 's say I have the following code... | Where should I create an Exception object ? |
C_sharp : I have a task which runs a loop and delays for an interval each iteration . Once the CancellationTokenSource calls Cancel ( ) I want my main code to Wait ( ) for the Task.Delay ( interval ) to finish and the task to exit the loop before my code continues . I thought this code would work but it does n't . Inst... | Why is this Task not Finishing before my code passes the Wait Command |
C_sharp : I would like to be able to create various structures with variable precision . For example : I know Microsoft deals with this by creating two structures - Point ( for integers ) and PointF ( for floating point numbers , ) but if you needed a byte-based point , or double-precision , then you 'll be required to... | Are there any interfaces shared by value types representing numbers ? |
C_sharp : I have code that is building up a collection of objects . I 'm trying to reduce the number of .ToList ( ) calls I make , so I 'm trying to keep it as IEnumerable < T > for as long as possible.I have it almost finished except for two properties which need to be set to a value which is passed into the calling m... | Any way to project `` original plus a few changes '' with a LINQ query ? |
C_sharp : I 'm trying to join two different class models in an MVC project together so I can order them ascending/descending . I 've tried several permutations but ca n't seem to get the LINQ query to play nice . Any suggestions on what I 'm doing wrong ? I 'm a beginner when it comes to this , but if I 'm understandin... | LINQ Join Query Structure Resulting in CS0119 Error |
C_sharp : I 'm trying to mock a third-party interface that I 'm using ( EventStore ClientAPI/IEventStoreConnection ) , in particular this method : The problem I 'm having is that the return type StreamEventsSlice has readonly fields and an internal constructor i.e.In my test code I 'm mocking the event store connection... | Mock third-party interface with return type that has readonly props & internal ctor |
C_sharp : I am having some problems with a quite easy task - i feel like im missing something very obvious here.I have a .csv file which is semicolon seperated . In this file are several numbers that contain dots like `` 1.300 '' but there are also dates included like `` 2015.12.01 '' . The task is to find and delete a... | Delete character out of string |
C_sharp : Linq to objects works on any IEnumerable object . The variablesandare both IEnumerable < string > , but if I want to know how many items each one of them has , I can use Length property on the array and Count property on the list . Or I can use the Count method from Linq , which will work for both.The questio... | Does Linq optimizes execution based on real collection type ? |
C_sharp : Why does this code prints False ? Do I understand correctly that when compared , they are compared not as strings , but as objects , which is why not their values are compared , but the addresses to which they point ? <code> class Program { public static void OpTest < T > ( T s , T t ) where T : class { Conso... | Comparison of Generics in C # |
C_sharp : I am trying to save data using soap Jquery with C # WebMethod But can not save data in SQL Server please help me how can I save data using Soap jquery.I am using IDE Visual Studio 2015 . <code> < script type= '' text/javascript '' > function SavePersonRecord ( ) { var Name = $ .trim ( $ ( ' # < % =txtName.Cli... | How Can I save Data using Soap Jquery in SQL Server 2012 ? |
C_sharp : Given the following code : the results are as in the comments - both lines print 666.I 'd expect Console.WriteLine ( new B ( ) ) ; to write 667 , while there is a double overload of Console.WriteLine.Why is that happening ? <code> using System ; namespace Test721 { class MainClass { public static void Main ( ... | Conversion rules for overloaded conversion operators |
C_sharp : I am initialising and array from items in a list as follows : I have a secondary List that i would like to add to the same array inline in the initialiser , something like this ( ) : Is this possible or will i have to combine everything before the initial select statement ? <code> MyArray [ ] Arrayitems = Som... | Combing Array Inline - LINQ |
C_sharp : I have a C # .NET classes that exist outside of a namespace that need to be accessed inside of IronPython . Typically I would do : However , I do not have a namespace . <code> import SomeNamespacefrom SomeNamespace import * | How do I import non namespaced types into IronPython ? |
C_sharp : I just can not understand why s3 interned , but ReferenceEquals was False . Dose they have two copies in intern pool ? Thanks in advance . <code> string s1 = `` abc '' ; string s2 = `` ab '' ; string s3 = s2 + `` c '' ; Console.WriteLine ( string.IsInterned ( s3 ) ) ; // abcConsole.WriteLine ( String.Referenc... | Why string interned but has different references ? |
C_sharp : I have a class like this : And I have to make a search by the value received from the user , it could be , any attribute of this class . I have this too : I have four methods like this , the only difference is the attribute . Please , can anybody tell me how can I do this in just one method or is n't possible... | Linq search by differents values |
C_sharp : String object behaves like a Value type when using == and ! = operators which means the actual object rather than the reference is checked.What about parameter passing , assignments and copying ? String Parameter Passing : When a reference type is passed to a method , its reference is copied but the underlyin... | How a String type get Passed to a Method or Assigned to a Variable in C # ? |
C_sharp : I 'm trying to create some expression at runtime to change a given dictionary 's values . I created this snippet which generates the expression successfully and compiles it an Action . But calling the action can not modify dictionary 's value , and also does n't throw any error . Here is the code : As you can... | Runtime generated expression can not change dictionary 's values |
C_sharp : I am new to C # and I am trying to print out a number from a different namespace in my main . I will provide the code below.I want to have the x from Program2 class appear in my main which is in Program Class . <code> using System ; using System.Collections.Generic ; using System.Linq ; using System.Text ; us... | How does connecting Namespaces work in C # ? |
C_sharp : I am newbie to C # and I 'm doing some easy practices in VS code.I have an array of colors and a method that returns the corresponding index of the inputted color ( Resistor Color exercise ) .I want to see the result of the program when I run the program in the terminal , but nothing shows ! For example , whe... | Why I can not see the output of the program I wrote in C # in VS Code when I run it in the terminal |
C_sharp : I Have following problem : is it possible to do it ? <code> class Request < T > { private T sw ; public Request ( ) { //How can i create here the instance like sw = new T ( ) ; } } | How to set/create a Generics instance ? |
C_sharp : Is it good approach in the model binder use the code like this : And then `` format '' is a variable with different ( customer specific ) date format . Like 12/31/2013 or 31.12.2013 or other ones.I have big problem with the format binding because if user puts the date with only 1 digit like : 1/1/2014 it will... | What is the best way to parse dates in binder |
C_sharp : I have an application has a collection of domain objects that need to be updated in real-time . Several threads can take action that modify the items in this collection and must do so safely . The current approach is rather simplistic , taking essentially a global lock before making any changes . More or less... | How do I efficiently support both item- and collection-level locking ? |
C_sharp : UPDATEthanks to @ usr I have got this down to ~3 seconds simply by changingtoI have a database with two tables - Logs and Collectors - which I am using Entity Framework to read . There are 86 collector records and each one has 50000+ corresponding Log records . I want to get the most recent log record for eac... | How can i improve the performance of this LINQ ? |
C_sharp : I have a winforms project which depends on a custom library . Everything with the app is working fine except a problem I can not pin down . Basically I have a form which is created from another form which displays it as a dialog : This dialog form populates a dropdown list from the SqlServer using the below f... | Break in dubugger not `` working '' .. code execution continues |
C_sharp : Output of the following code : isIsZeroA : False , IsZeroB : TrueStrangely , when I put a breakpoint after if ( count == 323 ) while debugging and put expression ( a * 0.1 ) == 0 in Visual Studio Watch window , it reports that expression is true.Does anyone know why expression a * 0.1 is not zero , but when a... | Why storing a value in a variable changes the outcome of equality comparison ? |
C_sharp : That might not be the best way to phrase it , but I 'm considering writing a tool that converts identifiers separated by spaces in my code to camel case . A quick example : I was wondering if writing a tool like this would run into any ambiguities assuming it ignores all keywords . The only reason I can think... | Is there a syntactically legal expression that has 2 consecutive identifiers separated only by white space in C # ? |
C_sharp : This code works : This code does not compile : CS1061 'int ? ' does not contain a definition for 'Parse ' and no extension method 'Parse ' accepting a first argument of type 'int ? ' could be found ( are you missing a using directive or an assembly reference ? ) My example may look silly , but it makes a lot ... | Why does making this getter nullable cause a compile error ? |
C_sharp : I am using code quality tools and they are saying that I can have a null deference on line 3 in the following block style : It sugests making the following change : How does this change the potential for a null deference exception ? According to msdn is will return true if `` provided expression is non-null ,... | Can the result of as operator be null if the is operator returns true ? |
C_sharp : Here 's the code : The result is $ 11000.I 'd like to have 01000 from 00000.But , I guess , $ 1 is confused with $ 11 . <code> string myVar = `` 00000 '' ; string myPtrn = `` ( . ) . ( ... ) '' ; string mySub = `` $ 1 '' + `` 1 '' + `` $ 2 '' ; string myResult = Regex.Replace ( myVar , myPtrn , mySub ) ; Mess... | Substitution number confusing |
C_sharp : This is really puzzling me . I know LINQ-to-SQL handles selects by processing the expression tree and attempting to translate stuff via the generated query , which is why some function translations do n't work property ( string.IsNullOrWhitespace is a regular annoyance ) .I hit a situation in my code where LI... | Why does LINQ-to-SQL sometimes allow me to project using a function , but sometimes it does not ? |
C_sharp : Yesterday , after running Visual Studio code analysis on our codebase , the following code was highlighted as an issue : The warning that was returned was Warning CA2202 Object 'stringReader ' can be disposed more than once in method ' ( method name ) ' . To avoid generating a System.ObjectDisposedException y... | What is the resulting behavior when an IDisposable is passed into a parent IDisposable |
C_sharp : I understand that in .NET , finalizers are run even if an object is partially constructed ( e.g . if an exception is thrown out of its constructor ) , but what about when the constructor was never run at all ? BackgroundI have some C++/CLI code that does effectively the following ( I do n't believe this is C+... | In .NET , can a finalizer be run even if an object 's constructor never ran ? |
C_sharp : I am trying to implement a command pattern with strongly typed input and output parameters for the command itself . First of all I have created two interfaces that marks the input and the output for the command : Then I have created the base classes and interfaces . This is the abstract receiver and this the ... | Type error in command pattern |
C_sharp : I just learned that having a generic argument as the type of an out parameter forces that generic type to be invariant . This is surprising to me . I thought out parameters are treated the same as return types ( i.e . if the generic parameter is covariant , then it can be used in as an out out parameter ) , s... | Why ca n't I convert from 'out BaseClass ' to 'out DerivedClass ' ? |
C_sharp : Given this class : This code snippet does n't compile : error CS0266 : Can not implicitly convert type 'System.Collections.Generic.IEnumerable < int > ' to 'Spikes.Implicit.Wrapper < System.Collections.Generic.IEnumerable < int > > ' . An explicit conversion exists ( are you missing a cast ? ) But the compile... | Unable to implicitly 'wrap ' an IEnumerable |
C_sharp : I get objects byHow can I get a List of the objects with a type given by a string ? <code> IEnumerable < ObjectStateEntry > om = context.ObjectStateManager.GetObjectStateEntries ( System.Data.EntityState.Modified ) ; Type typ = Type.GetType ( `` mytype '' ) ; var om2 = om.Select ( s = > s.Entity ) .OfType < t... | Getting List of Objects by a type given by a string |
C_sharp : I have a buffer of type ReadOnlySequence < byte > . I want to extract a subsequence ( which will contain 0 - n messages ) from it by knowing that each message ends with 0x1c , 0x0d ( as described here ) .I know the buffer has an extension method PositionOf but itReturns the position of the first occurrence of... | Is there something like Buffer.LastPositionOf ? Find last occurence of character in buffer ? |
C_sharp : I 'm puzzled with a problem regarding C # List , the code below throws ArgumentOutOfRangeException : As far as I understand the code above , the method will apply the lambda from the element 0 until it reaches 5 elements ( element 4 ) , but it throws the ArgumentOutOfRangeException even if it must n't accordi... | FindLastIndex ArgumentOutOfRangeException when parameter count is less than List.Count |
C_sharp : I have a scenario where I need to join two tables : ABI need to use LINQ 's query syntax to join these two tables.The left table needs to be Table A.Though I need to join based on whether the `` text '' column contains the text from the Name column in Table A.The code should look something like this : I ca n'... | Join in LINQ Query Syntax : moving right side to the left |
C_sharp : If I have a class as below : But construct it using the same types ( new MyClass < int , int > ( ) ) This compiles fine , but if I try to call DoSomething it errors because of an ambiguous call , which of course is correct . But what if the method was called through reflection or some other dynamic way . I gu... | 2 methods using 2 generics of same type |
C_sharp : I 'm querying a collection using linq and grouping my data by datetime property using the following code : Everything is good , when use an anonymous type . But If I define my own classand modify my query accordinglythen grouping is not working and I 'm getting a plain list of the objects . Why ? <code> var q... | Using strict types in linq grouping query |
C_sharp : In an effort to learn more about Func Delegates and Expression trees , I put together a simple example , however I am not getting the results I expect . Below is my code that has a Func that expects a Params class and a List of Products . The idea is to apply the Params Class as a filter against a list of Pro... | Returning values with a Func Delegate |
C_sharp : I have been reading about an implementation of the diamond-square algorithm in C # that wraps around to create seamless textures . To calculate the next point , an average is taken of four sample points arranged in a square or a diamond . If a sample point lies of the edge of the texture , it is wrapped aroun... | What is the function of bitwise & in this statement ? |
C_sharp : Access base class A function by derived class B object in c # Is there is any way i can access function ( Sum ) of A class By B class object and get output 10. ? <code> Class A { public int Sum ( int i ) { return i+3 ; } } Class B : A { public int Sum ( int i ) { return i+4 ; } } B objectB=new B ( ) ; int res... | Access base class A function by drived class B object in c # |
C_sharp : I just have a function here that caller wants number of bytes and then it returns the bytes but if there are not enough bytes in file it should return an smaller array . is there better approach to do this ? I mean not getting 2 array and use BlockCopy ? <code> byte [ ] GetPartialPackage ( string filePath , l... | How to obtain a better approach in reading file ? |
C_sharp : I have a enum in my C # code and i want to get names from enum in my jQuery validate rules . Enum : Validate : This really works , but I want make something like this : In C # I can get names in this way : How can I make it in javascript ? Thanks for advice ! <code> public enum EnumItemField { Zero = 0 , One ... | How to use a C # enumeration in Javascript |
C_sharp : I have the following code that is executed by Hangfire ( there is no HttpContext ) and works perfectly when I run it locally : The way we have our application set up however is as follows : https : //application.net < - One applicationhttps : //application.net/admin < - The other application that this code ru... | Getting MVC5 Views as string , with nested hosting |
C_sharp : I have the following code that creates 10 threads which in turn write out messages to the console : My understanding is that ParameterizedThreadStart takes an object for which a copy of the reference is sent to the thread . If that is the case since I have not made a local copy of i within each loop all new t... | Captured variables in ParameterizedThreadStart |
C_sharp : I have an page and in my Send event , I need pass as a parameter an value `` Name '' .But this name have accentuation and , in example for name `` Raúl Lozada '' sends `` Ra & # 250 ; l Lozada '' to my procedure parameter.How I can correct it ? In my HTML page , it loads correctly ! <code> < asp : BoundField ... | Send parameter with accentuation c # |
C_sharp : VS2010 / R # 5.1I have this `` line '' of code : I perform a R # code cleanup , which changes the code as follows : That is , it reformats the statement such that it appears entirely on one line.What IDE/R # setting is responsible for this ? What can I change to preserve my line breaks when I perform a R # co... | What R # setting is reformatting this line ? |
C_sharp : Is it possible to check the type of a generic type , without using any generic parameters ? For example , I would like to be able to do something similar to the following ( actual types ' names have been changed to protect the innocent ) : The above code currently generates the following error : Is there a wa... | How can I determine the parameterless-type of a C # generic type for checking purposes ? |
C_sharp : I have a set of objects that themselves contain a set.Here 's some test data : I want to use OrderBy in Linq so that : Smith and Jones are ordered together because they fly the same planesHiggins and Wilson are ordered together because they fly the same planesdoes n't matter whether Higgins+Wilson end up befo... | Linq OrderBy to group objects with the same sets |
C_sharp : C # 6 introduced string interpolation and a shorter way to specify the format string . Why the two last lines output a different result ? Am I missing something ? Try it with DotnetFiddleAs a side note here is the source code of IntPtr ToString ( ) in dotnet core : <code> IntPtr ptr = new IntPtr ( 0xff ) ; Co... | C # 6 String interpolation + short format string bug ? |
C_sharp : By default , StringWriter will advertise itself as being in UTF-16 . Usually XML is in UTF-8.So I can fix this by subclassing StringWriterBut why should I worry about that ? What will be if I decide to use StringWriter ( like I did ) instead of Utf8StringWriter ? Will I have some bug ? After that I will write... | Should I be worried about encoding during serialization ? |
C_sharp : I have a ViewBag.List > where i have competition , and every competition has a list of teams.Example : List of { Premier League : [ Arsenal , Chelsea etc ] Bundesliga : [ Bayern Munchen , Wolfsburg etc ] I have 2 selects . When the user selects the first select ( competition ) , i want that the second select ... | < select > for < select > c # to javascript |
C_sharp : Suppose I got a parent class and a child class : As of current , both GetParentName ( ) and GetChildName ( ) will return Child.However , in my scenario , I 'd like to get the name of the class in which the method is declared.Thus GetChildName ( ) should return Child but GetParentName ( ) should return Parent.... | Getting the name of the declaring class ? |
C_sharp : I have managed to open my EA project via the automation API , but do n't know the right format in which to pass the arguments to the ImportDirectory ( … ) method : When doing the import manually I select the following options in EA 's Import Source Directory window : C # as programming languagerecursively pro... | In which format do I have to pass arguments to Project.ImportDirectory ( … ) ? |
C_sharp : I get a json string from an external web service . I would like to save the events from the events array in my database . How can I get List < FacebookEvents > ? My current attempt does n't work : List < FacebookEvents > my_obj = JsonConvert.DeserializeObject < FacebookEvents > ( jsonString ) ; Source json : ... | Parse json string with JsonConvert c # |
C_sharp : Assuming that I have the following three methodshow can I pass the functions Function1 and Function2 with designated parameters to the Execute method ? e.g . like thisbut above example is calling the function , I want it to be called only in the Execute method.I hope it got clear , if it does n't , I am looki... | Pass any function regardless of its parameters |
C_sharp : Every so often ( e.g . NUnit 's TestCaseData ) , I see an object that has one or several constructors as follows : If an object has the params constructor , though , what is the advantage of defining the previous ones ? <code> MyObject ( object arg ) MyObject ( object arg1 , object arg2 ) MyObject ( object ar... | Why have both params and muti-object constructors ? |
C_sharp : I want to use DbContext in multiple threads , but the underlying database has a problem if two threads are writing at the same time.So I am using lockObject to prevent two SaveChanges ( ) at the same time.That works fine in SaveChanges ( ) , but I do n't know how to do the same in SaveChangesAsync ( ) .I thin... | Locking async task c # |
C_sharp : I am currently doing some tests on F # maps vs C # dictionaries . I realize they are quite different implementation wise but they do fill the same sort of use for their respective languages.I have designed a simple test to check the insertion times due to the F # map being immutable thus it has to create an e... | Increase F # map insertion performance |
C_sharp : I have a panel with buttons . my buttons are create dynamically . I want to have 4 rows with 4 buttons each . but I only get one row.Desired result : <code> foreach ( CategoriesDataSet.CategoriesRow category in DataRepository.Categories.Categories ) { if ( ! category.CategoryName.Equals ( `` ROOT '' ) ) { Sim... | Controller wrapping in panel |
C_sharp : I 'm trying to skip duplicates for the list of values below . The result I 'm trying to achieve is -112.94487230674 , -49.47838592529 , -89.9999574979198 , I 'm using the HashSet class . I 've implemented the IEqualityComparer below but it 's not working.What am I doing wrong ? Here is the list of values : <c... | Avoid duplicates in HashSet < double > for slightly different values |
C_sharp : I have a ( hopefully ) simple question : I have some classes : I have two dictionaries : And I have a method : and a method call : but now I get the error that I ca n't convert Dictionary < int , Foo1 > to Dictionary < int , Foo > .How do I solve this problem ? Thank you : ) <code> class Fooclass Foo1 : Foocl... | Dictionary - inherited classes |
C_sharp : I have a list of objects with structure Sample data : My other list of objects is with structureSample data : I wish to change the second list to the first list structure and then do a union all ( concat ) with first list.So result ought to look as below : All help is sincerely appreciated..Thanks <code> stri... | merging two lists with diff structures C # |
C_sharp : I 'm beginner in the usage of threads and in the examples that I 've seen ( as here and here ) a new thread must be assigned to a method . But , is there a way of making that inside the method ? I 'm looking for something like this : Thank you . <code> public void MyMethod ( ) { //Start new thread that affect... | Start in a new thread in the same method |
C_sharp : Suppose we write a system for tests . Test contains the list of tasks and each task contains question and the list of answers . Also we assume that question or answer can be not only the text , but image for example . So we use generics : And the problem occurs when we creating the Task : How to write that TQ... | Using where constraints with generic interface or class |
C_sharp : Fairly basic question , imagineDo both a and b take up the same space in memory ? I assume b is larger than a as it has to store the length of itself somewhere , so I thought it would be IntPtr.Size larger , but I am not sure . I am trying to write code where the length of the array is determined at runtime ,... | Is an array of length 1 the same size as a single variable of the same type ? |
C_sharp : I have code like this : Works great but if row [ `` Forename '' ] is null in the database , it is actually DBNull here and it ca n't cast DBNull to a string , or perform the comparison between DBNull and string . Some values are also nullable < int > , and it ca n't compare DBNull with int ? Is there a helper... | Is there a neat way to compare nullable and dbnullable objects ? |
C_sharp : I was just experimenting and ended up with the following snippet : I did n't realize that a method name alone was the same as an Action.What is making this so ? <code> public static class Flow { public static void Sequence ( params Action [ ] steps ) { foreach ( var step in steps ) step ( ) ; } } void Main ( ... | What makes a name of a method equivalent to an action delegate ? |
C_sharp : Some simple rows of code below : When Visual Studio throws the null exception it references the following row and not the row where the exception occurred : I know the line number is correct when you view details of the problem . However , I often spend more time than necessary searching the wrong variables b... | Why is Visual studio referencing the wrong row during exceptions ? |
C_sharp : I have 3 different patterns of address : which means : [ address ] [ , ] [ number ] [ - ] [ county ] [ , ] [ state ] [ - ] [ country ] I 'm trying to use this regex but not working correctly : Regex testerany help please ? ty <code> Avenue T , 55 - Sumiton , AL - USAAvenue T - Sumiton , AL - USASumiton , AL -... | Regex for 3 types of address |
C_sharp : Consider the following example : Despite the fact that both lines have SolidColorBrush and both have opacity=1 , a color blending still occurs : The pixel at the point of intersection is of darker red color.Why does it happen and how can I prevent it ? Thanks ! P.S Here is another example of the same code wit... | How to prevent colors from blending ? |
C_sharp : Here is my generic method code : I 'd want to set that generic IT must be only an interface . Is this possible ? <code> public static IT Activate < IT > ( string path ) { //some code here ... . } | Is possible to point that the type used for a generic method , should be an interface ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.