Browsing 7239 questions and answers with Jon Skeet

New Thread does not see the supplied method from the same namespace

I am new to c# and I am trying to figure out what am I doing wrong in the following script. I am getting an error "Method Name Expected" when starting a new Thread for the "del"...
Jon Skeet
people
quotationmark

It's not really clear what you're trying to achieve, but currently you're calling del here: new Thread(new ThreadStart(del(targetUrl))) You've got a fundamental problem though - the method you're trying to call doesn't have the right... more 9/9/2014 11:00:18 PM

people

LINQ: Load XML into a Dictionary with value equaling new custom class instances

Struggling a bit with two LINQ statements here. Basically I would like to convert the following two XML files into dictionaries (type-detail to follow). Here are snapshots of the...
Jon Skeet
people
quotationmark

Enumerable.Cast doesn't perform custom conversions, which is what you want. You need to cast directly - but that's pretty simple: OffsetDictionary = XDocument.Load(folderPath+@"\offsets.xml") ... more 9/9/2014 10:40:55 PM

people

What is the reason for creating IEnumerator?

IEnumerator contains MoveNext(), Reset() and Current as its members. Now assume that I have moved these methods and property to IEnumerable interface and removed GetEnumerator()...
Jon Skeet
people
quotationmark

An iterator contains separate state to the collection: it contains a cursor for where you are within the collection. As such, there has to be a separate object to represent that extra state, a way to get that object, and operations on that... more 9/9/2014 11:55:39 AM

people

C# Hashcode Return value

For a given string "5", if I use the built in GetHashCode() function what is the value that is returned? Am I confused in that it returns the integer value of 5?
Jon Skeet
people
quotationmark

It's implementation specific, and you should not rely on anything you happen to observe in one particular implementation. Only rely on what is guaranteed: two equal strings will return the same value, in the same process. The same string... more 9/9/2014 5:30:48 AM

people

Parameter Replacement when the parameter is an complex object

I'm trying to create a dynamic AndAlso filter that will be used in a Where method to a LINQ-to-EF query: query.Where(filterExpression) where filterExpression is a compiled...
Jon Skeet
people
quotationmark

You're running into difficulties due to there being parameters embedded within your expression tree, I suspect. The replacer should only replace the top-level parameters. You could pass the top-level expressions into... more 9/8/2014 3:23:38 PM

people

Does not have matching return type error when using interfaces and generics

Why am I getting this error and how can I work around it when I CAN'T change the interfaces... (You can copy/paste the code into an empty CS file) namespace ClassLibrary1 { ...
Jon Skeet
people
quotationmark

Indeed, your Set method is meant to have a return type of IEntitySet<IEntity>, but you've tried to declare the implementation using EntitySet<Entity>. Two problems there: IEntitySet isn't EntitySet IEntity isn't Entity The... more 9/8/2014 3:02:40 PM

people

Difference between two String constructors

I'm wondering the difference between the following 2 statements: String str = new String(new char[]{'a', 'b'}); and String str = new String(new byte[]{'a', 'b'});...
Jon Skeet
people
quotationmark

The difference is that the first is just taking a character array and creating a string of the same length, with the same char contents. The second is decoding from bytes to chars - using the platform default encoding in this case. You can... more 9/8/2014 1:54:55 AM

people

How can I use a parameter in an interface that is defined by the interface

I try to define an interface like this: public interface Something { void f(); } public interface SomethingElse { void g(Something s); } This should say that g takes a...
Jon Skeet
people
quotationmark

Your SomethingElse interface says that any implementation needs to accept any type which implements Something - not just one specific example. Either you need to change SomethingElse_class to: class SomethingElse_class : SomethingElse { ... more 9/7/2014 12:54:57 PM

people

Stack overflow when creating a new instance of a class

I am new to Action Script and very confused about why I am getting a stack overflow. I will post all 3 classes (what's relevant). And the output I get. Can someone explain to me...
Jon Skeet
people
quotationmark

In order to create a Player, you create four new Finger objects... but each Finger object is also a Player (because Finger extends Player). Therefore creating each of those four Finger objects requires creating four more Fingers, etc...... more 9/7/2014 12:41:49 PM

people

Get value in xml from c#

This question must be easy, but I faced a problem, which I can't deal with. No matter what I try I am unable to parse this xml with linq and get the xml value. The error is...
Jon Skeet
people
quotationmark

This is one problem: name = title1.Element("name").Value, file= title1.Element("file").Value, info= title1.Attribute("info").Value)); Look at your XML: <setting name="file1" file ="example3.c" info ="open it!"... more 9/7/2014 7:46:20 AM

people