Browsing 7239 questions and answers with Jon Skeet

SimpleDateFormat parse returns bad date

I am using SimpleDateFormat in order to parse a String. Here is an example: private static final SimpleDateFormat longStringFormat = new...
Jon Skeet
people
quotationmark

Well, the problem is that you're specifying this value for the number of milliseconds: 376542900. That's 104 hours, 35 minutes, 42 seconds and 900 milliseconds... hence the issue. Unfortunately, it looks like SimpleDateFormat doesn't have... more 4/3/2014 3:32:21 PM

people

Typed and untyped delegates

What is the difference between var propertyResolver = Expression.Lambda<Func<Person, object>>(expr, arg).Compile(); string name =...
Jon Skeet
people
quotationmark

The first code is a call to Expression.Lambda<TDelegate>, which returns an Expression<TDelegate>, which has a Compile() method returning TDelegate. So the type of propertyResolver in your case is Func<Person,... more 4/3/2014 2:37:38 PM

people

My java program is giving me an IndexOutOfBoundsException

When my program enters this section of my code it crashes and produces this error public static boolean Search(ArrayList<String> ArrayToSearch,String word) { String...
Jon Skeet
people
quotationmark

This is the problem: found || counter < ArrayToSearch.size() If found ever becomes true, that will continue forever - or rather, until it goes bang because of this exception. I suspect you meant !found && counter <... more 4/3/2014 12:29:53 PM

people

how to handle System.IndexOutOfRangeException: There is no row at position 21

i have a string which consist of data in XML format.it consist of different tag like in VENUE tag which have 50 data & ARTIST tag which consist of 20 data. My problem is when...
Jon Skeet
people
quotationmark

Currently you're assuming that Tables[2] has as many rows as Tables[1], due to these two pieces of your code: for (int i = 0; i < ds.Tables[1].Rows.Count; i++) { ... dr["Performer"] =... more 4/3/2014 9:44:26 AM

people

How to access private data member outside the class?

I am trying to access the private data member of inner class outside the outer class. Please help me?
Jon Skeet
people
quotationmark

You don't - that's the whole point of it being private. The inner class can expose the data via a property, of course: public class Outer { public class Inner { private final String name; public Inner(String name) { ... more 4/3/2014 6:04:11 AM

people

Error: asking to create a new class while accessing innerclass

I am trying to access innerclass Class1 defined in ClassA from ClassB ClassB.java public class ClassB implements Initializable { public ClassA[] QR; @Override ...
Jon Skeet
people
quotationmark

When you declare a variable, the part to the left of the variable name has to be a type name. QR[i].Class1 isn't a class name. QR[i] is a value within an array. There isn't a different class for each value in the array. You... more 4/2/2014 5:44:17 PM

people

An Issue With Writing In A File In C#

I developed a simple program that asks the user if he wants to add a new record to a file or display all the records contained in the file, but I seem to have a problem in writing...
Jon Skeet
people
quotationmark

You're not closing the writer in the only situation in which you're using it - "choice 1". Basically the data is being buffered, and lost when the process exits because you haven't closed the writer. I would strongly advise you to: Only... more 4/2/2014 5:33:55 PM

people

Hashmap get(key) returns null even when the value is present

I'm trying to save datas in a hash map and retrieve it. The value corresponding to the key is present and it still returns null. I have implemented the equals() and hashCode()...
Jon Skeet
people
quotationmark

Your equals implementation only uses friendId. Your hashCode implementation uses both friendName and friendId. Therefore there can be two equal objects with different hash codes. Additionally, you're using == to compare strings within... more 4/2/2014 3:45:24 PM

people

c# How to look for specific pattern in a string?

I have a string containing letters and numbers. This string also contains a Date that I want to extract. example : anv749dld95hd01/01/2012ncjf739dkcju I want to get new string...
Jon Skeet
people
quotationmark

Well you could potentially use a regular expression: using System; using System.Text.RegularExpressions; class Test { static void Main() { var input = "anv749dld95hd01/01/2012ncjf739dkcju"; var regex = new... more 4/2/2014 3:35:13 PM

people

Cannot assign void to an implicitly typed local variable with var and foreach

I'm trying to list all buttons name from my form to list with code var v = new List<Form1>() { this }.ForEach(x => { x.GetType().Name.Contains(typeof(Button).Name);...
Jon Skeet
people
quotationmark

I suspect you're really looking for Where - just calling Contains in a ForEach call isn't going to do anything for you. Likewise I don't think you're really looking for a list of forms if you're interested in buttons. I suspect you may be... more 4/2/2014 2:21:15 PM

people