Browsing 7239 questions and answers with Jon Skeet

Adding second condition in LINQ JOIN,

I have looked around and found a few posts on adding a second condition to a JOIN clause but they are always instances of having one column link to another but in my instance I...
Jon Skeet
people
quotationmark

The condition tch2.WeekEndingDate = @PayPeriod doesn't feel like part of the join to me - it's not comparing data in two different rows. It feels like it should be part of what you're joining on, leading to: join leftth2 in... more 9/27/2016 3:39:11 PM

people

Android LEB128 type size

I'm confused about LEB128 or Little Endian Base 128 format. In the AOSP source code Leb128.java, its read function's return type whether signed or unsigned is int. I know the the...
Jon Skeet
people
quotationmark

Each byte of data in LEB only accounts for 7 bits in the actual output - the remaining bit is used to indicate whether or not it's the end. From Wikipedia: To encode an unsigned number using unsigned LEB128 first represent the number... more 9/27/2016 12:54:18 PM

people

Java: NoSuchMethodException with reflection when method clearly exists

I've been trying to use Reflection in Java, Here's my code: String charsetName = "UTF-16LE"; java.nio.charset.CharsetDecoder cd =...
Jon Skeet
people
quotationmark

You're calling getDeclaredMethod on the actual type of cd, whereas it's declared in CharsetDecoder. That can't be the actual type of cd given that it's an abstract class. Just change this: Class c = cd.getClass(); to Class c =... more 9/26/2016 12:35:49 PM

people

Is it possible to read ASCII control characters in XML?

I am newly on XML and I need to know, Is it possible to read ASCII control characters in XML? or Is it possible to replace ASCII control characters in XML?
Jon Skeet
people
quotationmark

XML 1.1 allows for all Unicode characters other than U+0000, but XML 1.0 has a restricted character set. From section 2.2 of the 5th edition: Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] That's the... more 9/26/2016 9:17:27 AM

people

Why does this download the large file, but hang the UI thread?

static async void DownloadData(TextBox textboxURL, TextBlock outputView) { try { using (var client = new HttpClient()) { client.BaseAddress =...
Jon Skeet
people
quotationmark

You're using the synchronous Stream.CopyTo method here: httpStream.CopyTo(fileStream); I think you just want: await httpStream.CopyToAsync(fileStream); However, you should also remove the StreamReader part - you're not using the... more 9/26/2016 7:21:53 AM

people

What will happen to the items inside a shallow cloned list if the original list was cleared

My initial intention is to send list asynchronously through a TCP Stream. But directly after passing the list to the asynchronous thread I need to clear it to fill it again with...
Jon Skeet
people
quotationmark

No, the existing items aren't affected, other than being potentially eligible for garbage collection. This is just like setting a variable to null, effectively: MyDataObject x = new MyDataObject(); // And populate MyDataObject y = x; //... more 9/26/2016 5:54:24 AM

people

Retrieving all records with Lambda StartsWith()

I have the following ActionResult and retrieve records that starting with "query" parameter's value. However, when quesry value is empty or null, the methods returns no record...
Jon Skeet
people
quotationmark

Well, two options: Conditionally apply the Where clause: IQuerable<StudentModel> students = repository.Students.Select(m => new StudentViewModel { Id = m.Id, Name = m.Name }); if (!string.IsNullOrEmpty(query)) { ... more 9/25/2016 5:12:55 PM

people

How convert list from one to another type using lameda Expression java

I have a list of Entities Employee(Class) which has fields empid, empname, emprole.salary List<Employee>= getting from database I want to convert it into model list...
Jon Skeet
people
quotationmark

Assuming you've got a suitable constructor, it should be as simple as: List<Person> people = employees .stream() // View the list as a stream .map(e -> new Person(e.getId(), e.getName(), e.getRole().getSalary())) ... more 9/25/2016 7:48:11 AM

people

Parse class variables?

I'm pretty new to c# language as I just started to use it several weeks ago, and I came across one simple problem with classes.I was sitting for good 30 minutes looking for...
Jon Skeet
people
quotationmark

I think you're confused about what your methods are doing, and when you're initializing objects. I suspect you actually want to do something like this: class Program { static void Main(string[] args) { // Ask the user for... more 9/23/2016 1:40:57 PM

people

Google Calendar API and shared hosting issue

I'm trying to use a public Google calendar in a webpage that will need editing functionalities. To that effect, I created the calendar and made it public. I then created a Google...
Jon Skeet
people
quotationmark

One simple option which avoids needing to worry about file locations is to embed the certificate within your assembly. In Visual Studio, right-click on the file and show its properties. Under Build Action, pick "Embedded resource". You... more 9/23/2016 12:59:57 PM

people