text stringlengths 46 37.3k | title stringlengths 12 162 |
|---|---|
C_sharp : I wrote a class that detects what is the current Excel theme.Get Excel current office theme : Then based on the value of themeCode , I can determine what the current Excel theme is : My question : How can I detect when the user , during Excel Running , change the Office Theme from the Excel Options ? In Anoth... | C # Visual Studio Excel Add-in : How can I detect Excel Office Theme Change ? |
C_sharp : Are the following C # -statementsandequivalent or are there any numerical caveats ? <code> double a , b = ... ; ! ( a > b ) a < = b | Is `` not > '' equivalent to `` < = '' for a double |
C_sharp : Is there any practical difference between these two extension methods ? I was poking around in Extension Overflow and I came across the first form , which I have n't used before . Curious what the difference is . <code> class Extensions { public static void Foo < T > ( this T obj ) where T : class { ... } pub... | Is there any practical difference between an extension method on < T > or on Object ? |
C_sharp : Im in the middle of porting my C # code to a F # library.I have the following interfaces/classes in my C # library : I have tried to port this to F # , this is what I 've come up with : The problem is , I need to call this F # library from my C # application.Before , when using the C # classes , I could do th... | Why does n't type implemented in f # behave the same as C # types when called from C # application ? |
C_sharp : I have two tables in my database : TPM_AREAS and TPM_WORKGROUPS . There exists a many-to-many relationship between these two tables , and these relationships are stored in a table called TPM_AREAWORKGROUPS . This table looks like this : What I need to do is load all these mappings into memory at once , in the... | Is there a quick way to get every association between two entities ? |
C_sharp : I 'm a contributer to the open source project Rubberduck , and looking to add support for the standalone VB6 IDE ( it currently supports VBA ) .One piece of information we need from the IDE is the mode it 's currently in - Design , Break or Run . On the VBA side , this is exposed by the extensibility API , ho... | How to query the mode of the VB6 IDE from C # |
C_sharp : My method returns in many points . I construct newData during execution also in many points . Regardless of where I return I need to save and store constructed result . Not to miss `` return '' I just surrounded the code with try-finally block so now I 'm sure that newData will be stored.But I do n't catch an... | is it good to use try-finally just to make sure that something is performed when method finished ? |
C_sharp : In the interface , I saw the following I want to know the meaning of `` new '' here . <code> public interface ITest : ITestBase { new string Item { get ; set ; } } | what the new mean in the following |
C_sharp : I have a linux ( ubuntu server 14.04 ) machine with 250 ips . When I run my c # code in mono , it only retrieves 50 ips.All ips are configured correctly , I have the same code in java , and all 250 ips are found , and can be bound to.I have tried : andboth return 50 ips ? So , my question , is there a limit i... | C # - Machine has 250 ips , I can only retrieve 50 from code |
C_sharp : I 'm receiving an error , `` unable to convert string to int ? '' . Which I find odd , I was under the notion when you utilize PropertyInfo.SetValue it should indeed attempt to use that fields type . The above would attempt to implement default ( T ) on the property according to PropertyInfo.SetValue for the ... | Holy Reflection |
C_sharp : I 'm tying to extract the header and a 2 or 3 digit ISO 639 code from a string.The general format of a valid string is : header + < special char > + < 2 or 3 digit code > + ( < special char > forced ) The last section < special character > forced is optional and may or may not be present but if present forced... | Extracting codes with optional special characters from a string using Regex in C # |
C_sharp : I have two classes : In a method which should returns an object of type Table , I try to filter an object of type Table with the Where-Statement and return this object after filtering.My problem is the cast of the resulting IEnumerable . Conversion with ( Table ) throws an InvalidCastException Additional info... | How can I cast a List into a type which inherits from List < T > ? |
C_sharp : I want to create a base class Student with a method changeName inside of it . I want studentclasses derived from the base class Student , such as collegestudent etc . I want to be able to change the names of the students.I have this code : I want to know if its possible to change the public virtual void chang... | C # method : is there a parameter name to insert 'derived classname ' generically ? |
C_sharp : I 'm trying to create a helper function ( for a class ) that accepts 2 objects and compares a property on both classesThese properties are only ever simple types like string , int and boolUsageWhat i have so farObviously the code above does n't work <code> Compare ( widget1 , widget2 , x = > x.Name ) private ... | How to create a method that accepts 2 objects of the same Type , a property , and compares the values |
C_sharp : I have a regex that I 've verified in 3 separate sources as successfully matching the desired text.http : //regexlib.com/RETester.aspxhttp : //derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx , http : //sourceforge.net/projects/regextester/But , when I use the regex in my code... | C # Regex Pattern Conundrum |
C_sharp : On C # , I 'm printing the JSONified string that I 'm sending to the console , and it reads asThen I do this to convert it to a byte array and send itAnd on the node.js side , I get this when console.logging res.body : That does n't look like valid JSON . What happened ? How can I send and receive the proper ... | Converting an object into Json in C # and sending it over POST results in a corrupt object ? |
C_sharp : By definition Nullable < > is a struct but when I call some generic function , it behaves like it 's an object.So the parameter is seen as an object instead of a struct.Any idea of what 's happening , am I misunderstanding the meaning of struct ? Is there a way to dispach Nullable < T > or T and object as dif... | Is `` long ? '' really a struct ? |
C_sharp : I need to make a method for displaying serial terms based on the number associated with these days.So , I base myself for each day ( term ) , set a specific number . Sun = 1 , Mon = 2 , Tues = 4 , Wed = 8 , Thu = 16 , Fri = 32 , Sat = 64If the user has chosen all eg working days , Mon - Fri = 62 , or weekend ... | Showing serial terms using the complex bit masks |
C_sharp : I 've been using the HttpClient in code for a while now and have always felt its use of Uris has resulted in some brittleness in my implementation . Most of our service endpoint base addresses are in the app./web.config . As a result , they can be easily changed . I 've found that when using these endpoint st... | Using Uri strings that may or may not have trailing / 's |
C_sharp : I ca n't get my head round this , threads all over SO state i 'm doing all the right things but clearly I must have missed something ... Given these two object defs ... And then context with the appropriate relationship configuration ... Why when I do this ... Do I get this exception ... The operation failed ... | EF 0..1 to Many Relationship updates |
C_sharp : Say I have this simple entity : The entity framework can infer by convention that the PersonID field is the primary key . However , if I give the model builder this class : Would that improve startup performance ? My thought was it might allow EF to do less reflecting and startup the app faster but I do n't k... | Is EntityFramework performance affected by specifying information like primary key ? |
C_sharp : At work I ran into a strange problem , where a loop I expected to terminate was actually running indefinitely.I traced the problem back to a use of Select.Interestingly , the loop terminated as expected when I added a .ToList ( ) right after the Select . I boiled it down to a small example.While I do n't have... | Why does Select turn my while loop into an infinite loop ? |
C_sharp : Can I do this using using var : or should I do this : or can I just go without disposing because the iterator is an IAsyncDisposable and the await foreach will do it for me ? <code> await foreach ( var response in _container.GetItemQueryStreamIterator ( query ) ) { using var safeResponse = response ; //use th... | How to safely dispose of IAsyncDisposable objects retrieved with await foreach ? |
C_sharp : Here I 'm working with a Java to C # sample app translation that involves cryptography ( AES and RSA and so on ... ) At some point in Java code ( the one that actually works and being translated to C # ) , I 've found this piece of code : After some googling ( here ) , I 've seen that this is a common behavio... | Why the need of a bitwise `` and '' for some char to byte conversions in Java ? |
C_sharp : I 'm doing a small assignment for school and I 'm having a bit of trouble . The purpose of the program is to sum up the roll of 2 random numbers 36000 times . The numbers should be in the range of 1-6 ( to simulate dice ) . We 're then to count the frequency of each summed value and display it to the console.... | Can not get array elements to display correctly C # |
C_sharp : I have an interface with two generic parameters , but one of the parameters is expected to be provided by the class implementation.However , another interface have a method that takes an instance of IA as a parameter - however , every instance must be the same ( the same class can take multiples X , but then ... | How to implement a generic parameter that is n't generic |
C_sharp : I have two Forms in my application . They way I call Form 2 is like this : Form 1 : Form 2 : My problem is if the user clicks the Add button , the error message shows ( because the data is invalid or the textboxes are empty ) BUT it closes the form . I only want the user to close the form and pass the data ba... | Form Closes When it Should n't |
C_sharp : i am designing a database and have theory problem , about which solution works better to run queries , to be faster on microsoft sql server or simply more relational.GIVENLets say , we have the following Tables : Congress , Person , Session , Room , and much more.Do n't mind about the given names . These are ... | SQL Theory Multiple References |
C_sharp : I 'm using the following code to convert radians to degrees and do some arithmetic on the same.The value calculates is inaccurate . I 'm using the same code in Python and the result is quite accurate as follows , How do I get the accurate degrees with c # ? Note : The output is after ( -135 - deg ) % 360 ; Th... | Calculation of degrees is inaccurate |
C_sharp : I 'm loading data from a MySQL database into a C # .NET application . The data is held in the database as DBType.Double , but for use in my application I cast to Decimal using Convert.ToDecimal ( ) . The data is positional data used in surveying and can be used to display a 3D model in a Direct3D window.When ... | Convert.ToDecimal giving different results when DirectX/Direct3D loaded |
C_sharp : I currently have this controller function : This currently gives me an error on my view page if I attempt to edit an item with an id of 100 , when there is no user with an id of 100 in the database.What 's the best practice for handling this ? Send them to a Create page , or show a friendly error message ? Sh... | Best practice for attempting to edit an item that does n't exist ? |
C_sharp : This C # does n't compile : The complaint from the compiler is : The type 'IdList ' already contains a definition for 'Item'If I comment out the indexer , it compiles.How can I get this to compile ? Rider does n't have a fixit.The unstylish workaround is not to nest the Item class.IDE is Rider 2018.1.4 , Lang... | Generic class whose parameter extends a nested class |
C_sharp : I 'm refactoring a big C # project and it 's only natural to find my snowman 's unused dead code.There 's this function called FooBar ( ) which looks useful since it has a bunch of code inside it . As is obvious , I was trying to find the references to this function using the `` Find All References ( F9 ) '' ... | Is the Find All References in Visual Studio good enough to judge if a piece of code is unused ? |
C_sharp : I am trying to cast a float into a byte array of length 4 , and then back again . But I it doesn 's seems to work.Here 's what I 've done : I expected fb = 90 , but it 's 1.26E-43.I know that my converter is little endian , so I 've also tried to reverse the array , like this : Then I got the answer fb = 9.0E... | Byte array to float |
C_sharp : I 've got 3 C # projects/assemblies , A , B and C. B references A , C references B.In A : In B : In C : This all compiles.If I import the System.Linq namespace in Project C and add the line strings.Select ( s = > s ) ; ( or any LINQ method ) before the call to client.M ( ) , I get a compiler error : The type ... | Reference required error only when using LINQ |
C_sharp : I have a third-party assembly that has a huge struct with lots of members of different types in it . I need to take some of the values from that struct and process them . So I write overloads for different types . I know what I need to do with ints , with chars , etc . And if some value is a key value pair , ... | Generic method takes KeyValuePair . How do I forward the call to the correct overload taking the Key type ? |
C_sharp : So I 'm looking in to extending/adapting an API in my own need . I 'm speaking about the Lego Mindstorms C # API . I 'm building my own kind of API around it ( based on the adapter pattern ) so I can program the robot in a better OO way . Here 's the link about how the API works : Lego Mindstorms EV3 C # APIB... | Object Chaining vs. Methods in API extension |
C_sharp : I have this classand in below mapping , I fill in the value of 'Value ' using a procedure in a Formula ( ) But it returns the error when executing : Is there any way to use procedure in fluent nhibernate ? <code> public class Bill : EntityBase { public virtual decimal Value { get ; set ; } } public class MapB... | How to use database procedure in fluent nhibernate mapping |
C_sharp : I 've been programming for may years first Delphi and now c # so I thought I knew how overloaded method worked , but apparently not.First some codeI 've added a number to each call to CreateSettings in order for making it easyer to explain.My question as : Call # 1 calls the wrong ( Generic ) version of Creat... | How do overloaded methods work |
C_sharp : Using simple type likewith object intializers , one can writeBut the following is also accepted by the compiler : Same for int [ ] v = new int [ ] { 1 , 2 , } ; This looks a bit strange ... Did they forgot to reject the additional ' , ' in the compiler or is there a deeper meaning behind this ? <code> class A... | Why is the compiler not complaining about an additional ' , ' in Array or Object Initializers ? |
C_sharp : I 'm working with RPC ( protobuf-remote ) and I need to do some checking in case the other end ( server ) is down . Let 's say I 've lot 's of RPC methods , like : Is there anyway to change this repetitive null-checking code ? So I could write something like : Which would do null-checking and would create obj... | C # Repetitive code with null check |
C_sharp : This feels like a simple problem but I 'm having issues . DoSomething ( Vehicle vehicle ) does n't exist , so DoSomething ( vehicle ) throws an error , even though vehicle is `` guaranteed '' to be either Car or Bike . How can I convince the compiler that `` vehicle '' is Bike or Car , so that DoSomething can... | Polymorphic overloading - how to force an abstract type to `` act '' as one of its derived types for the purposes of overloaded parameters ? |
C_sharp : I 'm trying to create an expression that extracts strings greater than 125 from a given string input.Please view the link for further reference to my script/data example.DonotFiddle_Regex exampleHere is my current expression attempt ( * ) : From the above expression , the only output is 350A , J380S.However I... | Extract specific values using Regex Expression |
C_sharp : I 'm trying to figure out if there 's a way to do something in C # that 's fairly easy to do in C++ . Specifically , if I have an array of data , I can create a pointer into that data to access a subsection more conveniently.For example , if I have : and I determine that there 's a string at positions 102 to ... | Way to access subset of array ? |
C_sharp : Assume I have the following two classes : I created two mapping classes : This will result in a table Item that has a column UserId and a column OwnerId . When I use KeyColumn ( `` OwnerId '' ) on the HasMany mapping , it works with only the OwnerId column , but I would like to avoid that . Is there a way to ... | Avoid specifying key column in double linked scenario |
C_sharp : Quite often I find myself dealing with a pattern similar to this oneTwo inheritance trees , where there is some kind of mirroring . Each of the subclasses in the left tree has a different subclass in the right tree as sourceThe MappingEnd class : The question is , how to deal with that in the subclasses . Do ... | Dealing with mirrored inheritance trees |
C_sharp : I have a GroupSummary class that has some properties like this in it : Then I have a Dictionary like < string , List < GroupsSummary > For each of these dictionary items I want to find all the distinct addresses but the properties of this class that define a distinct address for me are I know as far as I can ... | Finding the distinct values of a dictionary |
C_sharp : Given the following class definitionSomewhere else in my code , I would like see the attributes on the event.But I am seeing only BrowsableAttribute in that attributes collection.How can I get the field : NonSerialized attribute info ? <code> public class MyClass { [ System.ComponentModel.Browsable ( true ) ]... | Inspecting the attributes on the generated field behind a field-like event |
C_sharp : The Students object has Name and Weight key-value pairs.In the ToDictionary method , t variable is of type IEnumerable < IGrouping < K , T > > . That is , IEnumerable < IGrouping < int , Students > > Why are the Key values returned by t= > t.Key and t= > t.Select ( **x= > x.Key** ) different ? They both use t... | Difference between the returned values of two selector functions in this code |
C_sharp : IN THE LAST PART I WROTE THE working solution : I have this stored procedure in SQL Server : and I am passing the parameters but I can not retrieve the SELECT part I need to retrieve B , M , V of Select B , M , V alsoTHIS IS THE WOKING SOLUTION THANKS TO THE HELP I GOT HERE : <code> alter PROCEDURE [ dbo ] . ... | How to send and receive parameters to/from SQL Server stored procedure |
C_sharp : I 'm writing a program in which the user can type in some informations about a customer and then open a MS Word model ( *.dotx ) . After that he can directly archive it with another program . So I click on a button which I created for MS Word and then it should open the other program ( the archive program ) a... | How to avoid that a string splits on every whitespace in command line |
C_sharp : With C # 6 came some new features , including getter-only auto-properties and property-like function members.I 'm wondering what are the differences between these two properties ? Is there any reason why I 'd prefer one to another ? I know that { get ; } = can only be set by a static call or a constant value ... | Readonly getters VS property-like functions |
C_sharp : Consider the following code from a standard System.Windows.Forms.FormIt produces this result : Why are the red and blue lines showing up in the incorrect order , and how can this be fixed ? <code> protected override void OnPaint ( PaintEventArgs e ) { base.OnPaint ( e ) ; Rectangle test = new Rectangle ( 50 ,... | LinearGradientBrush does not render correctly |
C_sharp : Scratching my head . What 's wrong with the following statement ? encrypt is bool , both of the functions Encryption.Encrypt and Encryption.Decrypt have the same type Func < string , string > , but it tells me that : CS0173 Type of conditional expression can not be determined because there is no implicit conv... | Why compiler ca n't determine the type of operands in this case ? |
C_sharp : An event can contain many handlers which are defined using delegate , my current understanding is that delegate is just an abstraction of function pointer . Since an event , which associated with a delegate type , can add / remove many delegates into it , and composite pattern treats a composite object the sa... | Can I say that the relation between events and delegates adopts composite pattern ? |
C_sharp : For example : -I 'm looking for a way to test this before runtime , ideally in an automated test isolated from the database.I spent some time trawling through MSDN trying to find how to instantiate my own QueryProvider , but my Google-fu appears to be failing me today.Thanks in advance ! <code> // This one wi... | Is it possible to test whether a given expression can be converted to SQL *without* connecting to a SQL database ? |
C_sharp : I 've encountered some rather bizzar exception while constructing connection string in my application.Error : An unhandled exception of type 'System.FormatException ' occurred in mscorlib.dllAdditional information : Index ( zero based ) must be greater than or equal to zero and less than the size of the argum... | Difference between index of List and index of Array |
C_sharp : this is my app to excute a threading example , but the output is not as expected , anyone have any clue about that please but the out but is 3__3__3__3__3__3__3__3__3__3__4__4__4__4__4__what happens exactly anyone can explain please thanks <code> using System ; using System.Collections.Generic ; using System.... | multithreading behavior strange C # ! |
C_sharp : I 'm trying to write a function that takes a function as one of its arguments -- a task I 've done many times before . This works fine : Yet this does n't work : Any idea why the first one works and the second one does n't ? <code> int RunFunction ( Func < int , int > f , int input ) { return f ( input ) ; } ... | Function of a function works one direction , not the other |
C_sharp : I have a library with the following code : In my local copy of Visual Studio 2015 this compiles fine . Last week the build server would let this compile without a problem as well . Suddenly , on Monday the build server started having the error : QueryParser.cs ( 449,53 ) : error CS1620 : Argument 2 must be pa... | Getting `` ref '' keyword required in Double.TryParse |
C_sharp : Hallo and thanks for your time.I have recently decided to try using Xamarin.Android , to develop an idea I had.However , I 've run into the weirdest problem I 've ever had.In the above class , when I do a ToString operation on a note object with less than 20 chars in it , I get an unhandled exception . Which ... | Unhandled exception in ToString overload |
C_sharp : One of my class collects statistics during application execution and I want to store this statistics to disk when application finished . I never destroy this class inside my program so I have tried to store logs to file like that : However I do not see logs I expect to see and also I can not `` catch '' in de... | correct way to store information to file when application shutdown |
C_sharp : I have a User table that has a BIT NULL column called NxEnabled , and I ca n't change . Some of the records actually contain a NULL in that column.I do n't want to have a Nullable in C # , so it makes sense comparing it to true in the projection ( the code is simplified , but this generates the same error ) :... | Why is this query throwing an exception ? |
C_sharp : Microsoft 's tutorial on events shows how to check an event for null before triggering it : But this leaves open a race-condition , as detailed in Eric Lippert 's blog , where he writes that events should be triggered via a local event to avoid a race-condition : While this works , it has confused many develo... | Potential downside to triggering an event ? |
C_sharp : Let 's say we have an interface likethat is co-variant in T.Then we have another interface and a class implementing it : Now the co-variance allows us to do the followingSo a IEnumerable < SomeClass > is assignable to a variable ( or method parameter ) of type IEnumerable < ISomeInterface > .But if we try thi... | Generic constraint ignores co-variance |
C_sharp : Say I have been provided a function that looks something like this : I want to use this function but I do n't need the uselessOutput variable at all . How can I get the function to work without using the uselessOutput , preferably without allocating any new memory ? <code> int doSomething ( int parameter , ou... | How to neglect/drop a c # `` out '' variable ? |
C_sharp : i write code : compile time error : Error 1 Operator '+ ' can not be applied to operands of type 'ConsoleApplication21.MyClass1 ' and 'ConsoleApplication21.MyClass1'So , c # compiler did not like line `` int j = new MyClass1 ( ) + new MyClass1 ( ) ; '' When i open ILDASM , i got same code of operator overload... | Why C # compiler generate error , even if using Attribute `` SpecialName '' |
C_sharp : Given the below console program : When compiled against .Net 4.5.2 using VS 2013 , it will print When compiled against .Net 4.5.2 using VS 2015 , it will print From this question , I kind of understand what is happening , but I 'm confused why there is a change in behavior between versions of VS. From my unde... | Why is Action.Method.IsStatic different between Visual Studio 2013 and 2015 for certain lambda expressions |
C_sharp : I 'm trying to log anything that my application outputs ( including information messages ) into the event log , but the ILogger interface only writes warnings and above there.Here is my program.cs : My appsettings.json : In my application I do the following : In the console output I receive all of the test me... | ILogger Interface not logging everything into Event Log / Core 3.0 |
C_sharp : I know the C # System.Collections.Generic.List object is not thread safe . But I am wondering why this piece of code generates null values.This is a part of the list after some seconds : The thread which is responsible to remove the entries from the list can crash , if the entry is not present in the list . T... | null values in List < string > when adding and removing in multiple threads |
C_sharp : I work on developing an external API . I added a method to my public interface : It looked good , until one test broke that was passing a null . That made the compiler confused with ambiguous call . I fixed the test with casting the null . However my question is : Should I change the name just because of this... | Changing the name just because of Null ? |
C_sharp : I am working on a BLE application . I am able to connect to MI band and get the services through my Xamarin forms BLE app . But when I am trying to write characteristics I am getting exception . I 'm getting exceptionCharacteristic does not support write.for the method WriteAsync ( ) . This is my code where I... | How to fix GattStatus : 3 - WriteNotPermitted exception for BLE Xamarin forms application ? |
C_sharp : I have txt file as follows and would like to split them into double arraysMy goal is to have a series of arrays of each column . i.e . node [ ] = { 0,1,2,3 ) , Axis [ ] = { 0.00 , -83.19 , -56.91 , -42.09 } , ... .I know how to read the txt file and covert strings to double arrays . but the problem is the val... | Split a string containing various spaces |
C_sharp : I want to find all subsets of a given set that are mutually exclusive and contain as many elements of the superset as possible . Where the user defines a meaning for exclusiveness : where at least exclusion ( a , b ) == exclusion ( b , a ) holds.And exclusion ( a , b ) == true is guaranteed if a.Equals ( b ) ... | Set of maximal independent subsets via a c # generator |
C_sharp : Assume I have this enum defined , where several members have the same underlying value : According to MSDN documentation : If multiple enumeration members have the same underlying value and you attempt to retrieve the string representation of an enumeration member 's name based on its underlying value , your ... | Properly identifying enums with same underlying value |
C_sharp : While trying to implement a GetHashCode override similar to Jon 's Skeet 's suggestion in What is the best algorithm for an overridden System.Object.GetHashCode ? I noticed some odd behavior in the order of evaluation that is causing a syntax error when doing a null check on a collection property in the class... | Why is the order of evaluation different for Collections than for other types using the conditional operator |
C_sharp : I have a console app ( c # ) which opens a connection to a sql database , executes a stored procedure and then exits.The stored procedure times itself ( using getdate and datediff ) and returns the timings to the console app.The stored procedure always reports taking about 100 milliseconds to execute.Running ... | why is a console app affected by having SSMS open |
C_sharp : I have this Json : I have created 2 classes to be used to Deserialize it.But when I try to access the dictionary , I keep getting Unhandled Exception : System.NullReferenceException : Object reference not set to an instance of an object . at `` Console.WriteLine ( jsonTest.Dict.Count ) ; '' Am I Deserializing... | Deserialize Json an access the result |
C_sharp : Can I make sure that in dictionary in C # there will be only a single of a specific value in it ? For example , if I define a Dictionary which key is char and value is char , can I make sure that if the character ' a ' is already an existing value , there wo n't be another value ' a ' in the dictionary ? I ha... | About Dictionary |
C_sharp : When I write Console.WriteLine ( new Point ( 1,1 ) ) ; it does n't call method ToString . But it converts object to Int32 , and write it to console . But why ? It seems as it ignores overridden method ToString . <code> struct Point { public Int32 x ; public Int32 y ; public Point ( Int32 x1 , Int32 y1 ) { x =... | Overriding virtual method in type with conversion method |
C_sharp : I have some code that can be called from inside or outside a lock . I need to do stuff when inside the lock . The code itself has no knowledge of where it 's being called from . So , I need something like this : I know it sounds weird and wrong but I need this for compatibility issues . Otherwise I will have ... | How do I check if current code is `` inside '' lock ? |
C_sharp : Recently I came across a proprietary third-party library and there is a method behave in this way : When my code calling this method from main thread , it will block on this method until user clicks , then get the point return from ClickOnDrawMat.However , it does n't block the main thread . I still can press... | Blocking calls but do not block thread |
C_sharp : I am trying to build a contact managers program in a console application using a list to store and display the data . I need to view a report that displays a summary of contacts available and then have a menu to allow the user to interact with the program . I have a method to create a contact and a contact ob... | remove item selected by the user from a list |
C_sharp : out of these which is better and why . or it is just a extra check . not a major difference . <code> private void NotifyFreeChannelsChanged ( ) //1 . { if ( FreeChannelsChanged ! = null ) { FreeChannelsChanged ( this , null ) ; } } private void NotifyFreeChannelsChanged ( ) //2 . { NotifyCollectionChangedEven... | Which is the better approach to invoke an event delegate ? |
C_sharp : I have the following class hierarchy : I need to be able to invoke any of these methods for a new instance of Child at any given time using reflection however to improve performance I need to resort to Delegate and/or Compiled Expressions.So for example I can have : for which I would need to at runtime invoke... | How can I convert C # methods to compiled expressions ? |
C_sharp : Long story short , I have this dataGridView and I want the cell [ 0,0 ] to be the cell on the lower-left corner of the grid , not on the top-left of the grid like it does by default.For example , visually , if i do something like : I get this ( sorry not enough reputation to post pictures ) but I 'd like `` a... | Windows Form : change dataGridView 's first cell origin ? |
C_sharp : If I have a method : I am able to call the method by passing in both a DateTime ? and a DateTime . So how does the compiler understand the difference ? Does that mean if I pass in a DateTime Value , the if statement will essentially be soemthing like and all the *.value has been changed to the proper objects ... | How does the compiler understand Nullables ? |
C_sharp : Back in time when .NET Reflector was free I used it to gasp into the .NET framework code . It came to my attention that most collections in .NET 2.0 ( I believe this is applicable for current versions too ) use the following mechanism to recognize collection modifications during loops : Now imagine the hypoth... | Modifying a built-in .NET collection int.MaxValue times and more - potential overflow error |
C_sharp : I have an asp.net application , which is crashing . There is an entry for this in the windows event logs which contains this callstack : This happens only on a customer machine and I was not able to reproduce it locally . As you see on the top there is an interface ( ILookup , which is really an interface , n... | Is it normal to see an interface in a clr callstack ? |
C_sharp : I was reading Improving .NET Application Performance and Scalability . The section titled Avoid Repetitive Field or Property Access contains a guideline : If you use data that is static for the duration of the loop , obtain it before the loop instead of repeatedly accessing a field or property.The following c... | Compiler optimization of properties that remain static for the duration of a loop |
C_sharp : I have a number of classes inheriting from an abstract base class Airplane , examplified : Suppose I want to create another class , AirplaneFactory that takes a list ( in the constructor ) of possible airplanes it can build : How do I limit those types to only Airplane and inherited classes ? The end goal is ... | Use list of class types ( or similar concept ) to limit valid input |
C_sharp : I have this query that i 've been trying to figure out how to convert to LINQ : And here is my LINQ so far : I am getting an error message on the first join stating '' The type of one of the expressions in the join clause is incorrect . Type inference failed in the call to 'Join ' . `` All searches I did , re... | Please help me convert SQL to LINQ |
C_sharp : When working on a repository i generaly try to keep the method pretty generic , but this can sometimes lead to calling longer methods , or creating more specificly named methods at the service layer . My question is , how much knowledge of your domain should your a resitory layer have ? For example , I curren... | How much knowledge of your domain should your repository layer have ? |
C_sharp : I have an interface that for example 's sake looks like this : I then have an abstract base class that looks like this : I then inherit from the base class like so : How can I instantiate a MyFoo from a generic method with type parameter FooBase ? I 'm pretty much looking for something like this : The problem... | Interface Base class instantiation via generic method |
C_sharp : I ran in to the following : I would love to be able to do this . But i think it 's impossible . The compiler ignores the constraints . Why ? ( I know it 's by design ) .I think my 2 options are : Make 2 distinct functions.Make 2 distinct Config classes.Right ? <code> public void AddConfig < T > ( Config c ) w... | uniquess of methods and constraints |
C_sharp : Is there any way to merge these two constructors into one ? Basically they accept the same array of Point3D type.Thanks . <code> public Curve ( int degree , params Point3D [ ] points ) { } public Curve ( int degree , IList < Point3D > points ) { } | Merging params and IList < T > constructors |
C_sharp : I just found out that you can use var as fieldname.Why is this possible ? Any other keyword as fieldname would not compile . <code> var var = `` '' ; var string = `` '' ; // error | How is var different than other keywords ? |
C_sharp : I 'm trying to access a asp.net variable ( c # ) from JavaScript/jQuery.I 've found a solution , here and here . But unfortunately these are not working for me.Here 's a snippet : Default.aspx.csscript.js_currentUser 's value is always `` < % =CurrentUser % > '' .Any ideas ? <code> public partial class Defaul... | Cant access Variables in JS/jQuery via < % = variable % > |
C_sharp : I am working on alpha.dubaiexporters.com.There is a go button clicking on which a search panel appears where I can perform search keyword and category.The issue is that after clicking on go button , search panel appears but if the user does not want to perform any search , he clicks outside anywhere but that ... | How to close a div by clicking outside anywhere ? |
C_sharp : So I do n't have an in-depth knowledge of how data is stored in the .NET Framework in terms of custom types , but I was looking for an explanation on how the casting system is working.For example , if one were to do an explicit cast from a ValueType Struct like Char into Byte as follows : I would be told that... | Casting Causes Different GetTypes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.