Browsing 15589 questions and answers with Jon Skeet

Download Google.Protobuf/3.1.0 nuget packages to local machine using powershell

I have got this below script in below blog which will Download all nuget packages to my local server using power-shell script. I have used same script to download...
Jon Skeet
people
quotationmark

https://www.nuget.org/packages/Google.Protobuf/3.1.0/ isn't a feed URL base - that's a page for a specific package. It looks to me like this: $serviceBase = GetPackageUrl($feedUrlBase) $feedUrl = $serviceBase + "Packages" can just be... more 3/22/2017 1:35:43 PM

people

how to specify a datetime object as a Central Standard Time or other timezones not UTC in C#?

please don't downvote without reading the full requirement. i am developing one web application where User calls to customers and Customer may be in different country so i need to...
Jon Skeet
people
quotationmark

DateTime itself only has three kinds: Unspecified (no specific time zone) UTC Local (system-local) It doesn't have the notion of being in a specific non-UTC, non-local time zone. If you want to convert from one time zone to another,... more 3/20/2017 4:39:25 PM

people

Return HashSet<T> from HashSet of generic type in generic function

I've got a Dictionary<Type, HashSet<GenericType>> which I use to hold my data in, and I am trying to make a function that returns one of those HashSets given the...
Jon Skeet
people
quotationmark

I would just change the type of the dictionary, and cast inside your Get method. Definitely, definitely make your dictionary private though - then you can make sure that only your code (ideally only the Get method) can access it: // Any... more 3/19/2017 4:53:40 PM

people

Covert UTC Date String to SQL Timestamp using Java 8

I have a Date String in UTC format with Zone. I have to convert it into SQL Timestamp with +/- Zone into time using Java 8.0 E.g. 2016-10-14T10:12:18.000+02:00 needs to be...
Jon Skeet
people
quotationmark

Well currently you're not doing anything to convert the value - you're using a ZonedDateTime, so it's preserving the time zone (at least, the offset) that was provided. (I'd use OffsetDateTime for this rather than ZonedDateTime, as you... more 3/17/2017 4:51:21 PM

people

Building VS 2017 MSBuild csproj Projects with Mono on Linux

I have .NET Core projects I am trying to build using Travis CI on Mac and Linux using the latest Mono and .NET Core 1.0.1 tooling (MSBuild based csproj tooling). They target...
Jon Skeet
people
quotationmark

There are two options here, as far as I'm aware: Install the reference assemblies (e.g. from myget) somewhere and use the DOTNET_REFERENCE_ASSEMBLIES_PATH environment variable to point to them. It's not clear whether this will work in... more 3/17/2017 3:23:42 PM

people

Failing to parse date in yyyyMMdd Hmm format using DateTime.TryParseExact()

I am getting my date time in a format like "20170317 630" which means 17 March 2017 6:30 am Here is the code block I am trying, but it is failing. var str = "20170317 0630"; var...
Jon Skeet
people
quotationmark

I'm not entirely surprised it's failing to parse that - I suspect it's greedily parsing the "63" and deeming that to be an invalid hour number. We have exactly the same problem in Noda Time - and I don't intend to fix it. Making this work... more 3/17/2017 2:27:21 PM

people

Simple Java array syntax which i'm confused over

public static void main(String[] args) { int[][] b = {{0, 0, 0, 1}, {0, 0, 1, 1}, {0, 1, 1, 1}}; int[] u = new int[b.length]; for...
Jon Skeet
people
quotationmark

b refers to an array of arrays. b.length returns how many elements b has - in other words, how many "nested" arrays you have. b[i].length returns how many elements b[i] has - in other words, the length of the nested array referred to by... more 3/17/2017 11:40:33 AM

people

cannot access class in the same package without adding to classpath

Project structure: ./src/com/example/Test.java ./src/com/example/Dog.java Test.java package com.example; public class Test { public void testing() { Dog d = new...
Jon Skeet
people
quotationmark

The compiler will treat directories on the classpath as source root directories - in other words, when trying to find classes for package com.example, it will look for both class and source files in a com/example subdirectory from each... more 3/17/2017 7:24:23 AM

people

cannot access class in the same package without adding to classpath

My project structure: .\listener_test\src\com\example\Dog.java .\listener_test\src\com\example\TestServlet.java .\listener_test\src\com\example\TestListener.java Whenever I try...
Jon Skeet
people
quotationmark

The compiler will look for source files for your package in a com/example directory relative to the current directory - but your source files are actually in src/com/example. So you could change to the src directory and run javac -cp... more 3/16/2017 9:08:22 AM

people

String was not recognized as a valid DateTime in c#?

I am write this code for date range filter in c# using linq.but getting like this error on server.in my local code working very well but deploy on server getting error. here i...
Jon Skeet
people
quotationmark

You're using a method that depends on the current thread's current culture - and the system time zone. You'd be much better off using DateTime.ParseExact in my view, and potentially specifying a DateTimeStyles value to force the use of... more 3/15/2017 8:57:42 AM

people