Browsing 7239 questions and answers with Jon Skeet

Java Reflection getGenericReturnType() error in Java 1.7

I have a sample class as following. class Sample { public List<BigInteger[]>[] method() { return null;} } When I try to do the following. Method m =...
Jon Skeet
people
quotationmark

You're just seeing a difference in the string representation of type argument. [LFoo is the normal (admittedly somewhat obscure) way that an array of Foo is displayed. It's not clear why this behaviour has changed (but only in one place)... more 9/18/2014 11:51:09 AM

people

How to write predicate for union join and inner queries?

I have a sql statement and I have to convert it into predicate to pass into a method. select * from applications where IsSuspended = 0 union select * from Applications where id...
Jon Skeet
people
quotationmark

It's not clear why you need a union at all here. Isn't it just an "or" condition? var query = applications.Where( x => !x.IsSuspended || !applications.Any(y => x.Id == y.ApplicationAssociationId)); (There's no need... more 9/18/2014 10:27:44 AM

people

How does adding a break in a while loop resolve overload ambiguity?

Consider this Reactive Extensions snippet (ignore the practicality of it): return Observable.Create<string>(async observable => { while (true) { } }); This...
Jon Skeet
people
quotationmark

Leaving async out of this to start with... With the break, the end of the lambda expression is reachable, therefore the return type of the lambda has to be void. Without the break, the end of the lambda expression is unreachable, so any... more 9/17/2014 7:21:57 PM

people

Class(implementing the interface) and interface in same file and accessing the class from a main class in different package

I was going through some design pattern videos on YouTube, however I have a small doubt on some basic Java concept. I tried searching for solution, but was unable to find one....
Jon Skeet
people
quotationmark

You've declared CantFly without any access modifier: class CantFly ... which means it's only accessible within the same package. Just make it public, and then you'll be able to use it within other packages. See the Java tutorial on... more 9/17/2014 2:22:01 PM

people

Disassemble signed dll

Just a thought came, many time I disassembled dlls to see the logic written, however is there any kind of security or restriction i can enforce on my dll something like creating...
Jon Skeet
people
quotationmark

No. Signing provides some extra information - it doesn't remove any information. All it means is that a client can verify that the code was signed by the owner of the key. (For example, you may have a list of the keys from trusted... more 9/17/2014 2:10:46 PM

people

Get Type of Object from String Value

I am writing a customer class which will read CS files and spit out information based on method names and their various parameters. This essentially reads each line looking for...
Jon Skeet
people
quotationmark

I've tried Type t = Type.GetType("My.Namespace.Classname"); but this just returns null even with the full namespace and name of my custom class object. I suspect that's because it's not in the calling assembly or mscorlib, which are... more 9/17/2014 2:05:27 PM

people

Passing dynamic object to C# method changes return type

I created a class that inherits DynamicObject and want to create a static method that can create new instances with pre-determined properties (stored in the Dictionary). public...
Jon Skeet
people
quotationmark

This is because almost any operation involving a dynamic value is resolved dynamically at execution time. There are no exceptions made for cases where actually there's only one method present at compile-time; the language is simpler that... more 9/17/2014 1:53:48 PM

people

Can InvokeMethod be used as optional parameters?

I have base class A in a project There are many subclasses that inherits from A public class A { public void Process(string myString1, int myInt1 ) { ...
Jon Skeet
people
quotationmark

Optional parameters are really a compile-time feature - the CLR and framework have very little to do with them, other than to make the information available via reflection. So while you can detect the fact that a parameter is optional... more 9/17/2014 12:17:44 PM

people

Naming a class in C# ? Noun recommended by MSDN?

The following class defines a template for printing a order invoice to company 1. Similarly, there are separate classes that define the template for printing order invoices to...
Jon Skeet
people
quotationmark

I suspect the word "print" is confusing things here. You probably wouldn't think of it as a problem if it were PdfTemplateClient1 for example. However, I would try to put the noun at the end - I'd use Client1PrintTemplate, to go along with... more 9/17/2014 6:24:13 AM

people

Will String.getBytes("UTF 16") return the same result on all platforms?

I need to create a hash from a String containing users password. To create the hash, I use a byte array which I get by calling String.getBytes(). But when I call this method with...
Jon Skeet
people
quotationmark

Yes. Not only is it guaranteed to be UTF-16, but the byte order is defined too: When decoding, the UTF-16 charset interprets the byte-order mark at the beginning of the input stream to indicate the byte-order of the stream but defaults... more 9/16/2014 7:15:42 PM

people