Browsing 7239 questions and answers with Jon Skeet

Endless loop with InvokeMember c#

I'm trying to mark some checkboxes and then submit a form using webbrowser, I succeeded, the problem is that my program is getting endless, It appears the form submitted, and then...
Jon Skeet
people
quotationmark

Well you've said that any time you finish loading a page, you want to submit the search form. So when that submit finishes, it will finish loading the page... and you'll trigger the same event. It's an entirely natural loop. You should... more 3/7/2014 9:49:55 AM

people

When must I close database connections? (Java)

So I have a Java process that runs indefinitely as a TCP server (receives messages from another process, and has onMsg handlers). One of the things I want to do with the message...
Jon Skeet
people
quotationmark

I do NOT close and reopen the connection for each message. Yes you do... at least as far as the plain Connection object is concerned. Otherwise, if you ever end up with a broken connection, it'll be broken forever, and if you ever... more 3/7/2014 7:23:57 AM

people

Convert TZ type of date to java date

I'm getting time stamp from the server like- "2014-03-05T13:00:07.341Z" I want to set this to android calendar and convert the time stamp to am/pm. I have done the following...
Jon Skeet
people
quotationmark

If you want to convert to a specific format, you should use a separate DateFormat for that. Currently you've only shown code to parse, and that just returns a Date - an instant in time. You'll need to work out everything you need about... more 3/7/2014 7:15:47 AM

people

JAVA Bad variable reference? Receiving strange output possibly memory address?

public class working { public static String str = "123zASdcvb/;["; public static void main(String[] args){ System.out.println("!!!"+new LetterInventory(str)); ...
Jon Skeet
people
quotationmark

You're calling toString() on an array - arrays don't override toString(), so you end up with the implementation from Object: The toString method for class Object returns a string consisting of the name of the class of which the object... more 3/7/2014 7:06:03 AM

people

Array Index out of bounce in C# when string in splited

hello friend this is my code which i am using following code for splitting the string string s = dt.Rows[0]["tstrim"].ToString(); for (int i = 0; i...
Jon Skeet
people
quotationmark

Yes, currently i can take every value within the length of s - and you're assuming that there are that many elements after splitting. You should split once, and then iterate over that: string s = dt.Rows[0]["tstrim"].ToString(); string[]... more 3/7/2014 6:53:14 AM

people

Int32.Equals vs '==' operator

I looked around but no one seems to have asked this question before, so here it goes. I'm working on a custom class that will have the IEquatable interface, and as such I'm...
Jon Skeet
people
quotationmark

Yes, using the == operator is absolutely fine, so long as the compile-time type of Order is int. If the compile-time type were object for example, then you'd be dealing with boxed int values and comparing those boxes with reference... more 3/6/2014 8:07:50 PM

people

List<string>.Contains using trim

It would be nice if this worked, but alas it doesn't. List<string> items = new List<string>(); items.Add("a "); bool useTrim = true; if (items.Contains("a", useTrim))...
Jon Skeet
people
quotationmark

Well you'll either need to loop through it each time, or create another list of just the trimmed values, and use that for searching. (Heck, you could create a HashSet<string> if you only need to know whether or not a trimmed value is... more 3/6/2014 3:06:27 PM

people

How to create website from XML documentation comments?

I would like to create a documentation website from C# XML documentation comments. An example from the Python community. This Scipy documentation is created from this python code...
Jon Skeet
people
quotationmark

Edit: The full extent of advice I could find in other questions was 'use Sandcastle'. As far as I can tell from its (ironically limited) documentation, it can only create Windows help files (.chm). Is that correct? No, that's not... more 3/6/2014 3:02:02 PM

people

Is it possible to make an anonymous class inherit another class?

This is a long shot, but I have a funny coding situation where I want the ability to create anonymous classes on the fly, yet be able to pass them as a parameter to a method that...
Jon Skeet
people
quotationmark

No. Anonymous types always implicitly derive from object, and never implement any interfaces. From section 7.6.10.6 of the C# 5 specificiation: An anonymous object initializer declares an anonymous type and returns an instance of that... more 3/6/2014 2:07:49 PM

people

accessor must be more restrictive than the property or indexer

I have the folowing class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.Odbc; namespace Framework { public class...
Jon Skeet
people
quotationmark

This is the problem: private OdbcConnection db { get; private set; } Assuming you really want both the getter and setter to be private, this should be: private OdbcConnection db { get; set; } The setter is already private, as that's... more 3/6/2014 2:01:58 PM

people