Browsing 15836 questions and answers with Jon Skeet

How to transfer a file from Google Cloud Storage to Compute Engine instance using gcloud terminal?

I would like to verify my website in Google Search Console by uploading a file to my website - example.com which is hosted on Google Cloud Compute Engine (Wordpress site deployed...
Jon Skeet
people
quotationmark

I don't know if there's a way of doing it in a single step, but it looks like it should be easy to do in two steps: $ gsutil cp gs://example/123googlesearchconsoleexample.html . $ gcloud compute copy-files... more 8/13/2017 2:01:36 PM

people

Why compiler and run time assuming the string return type as dynamic?

In C# 5 and VS 2017, I have, var json = JsonConvert.SerializeObject(items); // why json is dynamic here Clearly, SerializeObject returns string then why json is dynamic type...
Jon Skeet
people
quotationmark

Clearly, SerializeObject returns string then why json is dynamic type instead of string. Almost every operation involving a dynamic value is considered to be dynamic in turn. This includes method calls and most operators. The only... more 8/13/2017 1:45:06 PM

people

Overloading a class containing an explicit constructor with a call to super ( )

It appears that if a programmer supplied constructor, with a call to super ( ) is used, no other constructor can be invoked in that class ( i.e. it can't be overloaded)....
Jon Skeet
people
quotationmark

no other constructor can be invoked in that class ( i.e. it can't be overloaded). That's not true at all. The problem with your Two(int t, int y) constructor is that it doesn't chain to any constructor explicitly, meaning that there's... more 8/12/2017 1:12:34 PM

people

Why do I need to transform variable into final array inside @Override[inner class] method?

I'm using following code : public void addConditions(){ final String arriveHourse, departHourse, arriveMinutes, departMinutes; TimePickerDialog.OnTimeSetListener...
Jon Skeet
people
quotationmark

departHourse is a final variable. It has to be, in order to be used within the anonymous inner class. That means you can't assign a new value to it in the anonymous inner class. One way around that is to create a single-element array... more 8/12/2017 8:37:30 AM

people

Linq Group by won't work on multiple columns vb.net

I have a table like this: PRO_ID CATEGORY FINALLY_OK 200 1 55 200 1 60 200 2 65 200 2 ...
Jon Skeet
people
quotationmark

You're using an anonymous type to group, but you're not making any of those properties key properties... which means they aren't used in the equality tests. Try this: .GroupBy(Function(item) New With { Key .PRO_ID = item.PRO_ID, Key... more 8/12/2017 8:06:36 AM

people

Convert c# bytes array function to vb.net

I am trying to convert this code public static byte[] NewLine(this byte[] bytes, int feeds = 1) { return bytes.AddBytes(((IEnumerable<byte>) new...
Jon Skeet
people
quotationmark

It's not clear to me why specifying the type arguments fails, but that isn't needed anyway - and the location of CType looks to be broken. If you change the Select call to: .Select(CType(Function(x) CByte(10), Func(Of Byte, Byte))) then... more 8/11/2017 11:33:32 AM

people

Why should one use Objects.requireNonNull()?

Why should one use Objects.requireNonNull() ? I have noted that many Java 8 methods in Oracle JDK use Objects.requireNonNull(), which internally throws NullPointerException if...
Jon Skeet
people
quotationmark

But NullPointerException will be thrown anyway if a null object is dereferenced. So, why should one do this extra null check and throw NullPointerException? It means you detect the problem immediately and reliably. Consider: The... more 8/11/2017 10:29:55 AM

people

Using named tuples in select statements

Is there a nicer way to select a named tuple in C# 7 using a var target variable? I must be doing something wrong in example 1, or misunderstanding something completely. I seem to...
Jon Skeet
people
quotationmark

You can just use var, but you need to make sure the tuple elements are actually named. In C# 7.0, you need to do this explicitly: var tuples = source.Select(x => (A: x.A, B: x.B)); foreach (var tuple in tuples) { ... more 8/11/2017 10:07:44 AM

people

Suppress "Use of unassigned local variable" error?

I have a method like so: public static long? FromIpv4ToLong(this string ipAddress) { var octets = ipAddress.Split(IpSplitChar); if (octets.Length != 4) return null; ...
Jon Skeet
people
quotationmark

Just refactor the code to avoid the pointless local variable that's confusing things, taking advantage of the fact that within the if body, the compiler does know that everything is definitely assigned: public static long?... more 8/10/2017 1:58:35 PM

people

LINQ deferred execution with a function's result as source (e.g. Console.ReadLine)

A function's result is the source for a LINQ query. I want it to be evaluated lazily, every time I use the query, not be locked when I create it. This is an example of what I...
Jon Skeet
people
quotationmark

If you don't mind a bit of extra infrastructure, it's not too bad - you can create a DeferredEnumerable<T> class that just executes the given delegate every time it's asked for an iterator. A static non-generic class can then help... more 8/10/2017 12:03:25 PM

people