Browsing 15980 questions and answers with Jon Skeet

C# TimeZoneInfo to convert GMT timezone name to system timezone

In windows, we get timezone list like this: ID Time zone name Display string -- -------------- -------------- 0 Dateline Standard Time ...
Jon Skeet
people
quotationmark

If you're happy to stick with TimeZoneInfo and DateTime/DateTimeOffset, you can use Matt Johnson's TimeZoneConverter library to convert the IANA ID (the part in brackets, e.g. Pacific/Kiritimati) to a Windows system time zone ID. Examples... more 11/29/2017 9:51:08 AM

people

Async/await performance

I'm working on performance optimization of the program which widely uses async/await feature. Generally speaking it downloads thousands of json documents through HTTP in parallel,...
Jon Skeet
people
quotationmark

Task.Delay isn't broken, but you're performing 100,000 tasks which each take some time. It's the call to Console.WriteLine that is causing the problem in this particular case. Each call is cheap, but they're accessing a shared resource, so... more 11/26/2017 12:25:37 PM

people

Java variable declaration not allowed

I have made 2 pieces of code first work fine and other say that variable declaration not allowed here.Please any one can help me. First code(Working) class Test { public...
Jon Skeet
people
quotationmark

What the reason behind it i think both the codes are nearly same. Nearly, but not quite. To understand why the compiler is complaining, it's often a good idea to look at the language specification. The body of a ForStatement has to... more 11/25/2017 10:45:46 AM

people

Update nuget package referenced by package

I have a nuget-package A in my project that uses nuget-package B. When I update package B I alway have to update the nuget-package-rerefence to B in nuget-package A and then...
Jon Skeet
people
quotationmark

Is there any way to directly update the implicitly referenced nuget-package B in my top-level-project? Sure, just add a direct dependency from your project to package B - then you can specify the version you want. When package A is... more 11/23/2017 4:09:17 PM

people

Java SimpleDateFormat does not parse correctly (I am using the correct uppercase/lowercase letters..)

I know this has been asked several times and I am risking a downvote/duplicate close, but most of the questions posted here were resolved by chaing YYYY into yyyy..so, searching...
Jon Skeet
people
quotationmark

How is that possible? The new block was created before the old block, as seen in the timestamp. but now it is the other way around S in a SimpleDateFormat format string always represents milliseconds - not just "fractions of a second"... more 11/23/2017 11:12:16 AM

people

read file using InputStreamReader?

Basically I have a web-app and I am trying to read youtube API client_secrets.json using InputStreamReader and assign its value to Reader. I tried: Reader clientSecretReader =...
Jon Skeet
people
quotationmark

You're trying to load a file, but you're using Class.getResourceAsStream to do so. If you want to load a file, use a FileInputStream. If you want to load a resource which is accessible to a ClassLoader, use Class.getResourceAsStream or... more 11/22/2017 8:46:51 AM

people

Unicode.GetString in C#

I encountered a strange issue when doing some byte array stuffs together with unicode string in C#. Below is my code. var bytes = new byte[] {128, 216}; var strstr =...
Jon Skeet
people
quotationmark

From my opinion, GetString and GetBytes should be opposite operations. They are, when the data represents a valid string. However, you've tried to decode 0x80 0xD8 as a little-endian UTF-16 string - but that's not a binary... more 11/22/2017 6:27:48 AM

people

Read spreadsheet without knowing its range

I would like to read a spreadsheet without knowing its range. Is that possible in C#? Or else I have to specify the range till the values are inserted in the sheet? These things...
Jon Skeet
people
quotationmark

The documentation for A1 notation (which is what the range is expressed in) includes: Sheet1 refers to all the cells in Sheet1. So if you really want all the cells, just use that, without a trailing !. If you want to find out the... more 11/21/2017 7:32:03 AM

people

How are primitive data types made in C#?

How do System.float, System.int and other primitives types work? I never understood how it was possible to make primitives structs and I wonder if I could make my own numeric...
Jon Skeet
people
quotationmark

Assuming we're talking about a C# compiler which targets the Common Language Infrastructure (CLI), as almost everything does, it basically uses the primitive types exposed by the CLI. There are effectively three levels of support to... more 11/20/2017 8:12:56 AM

people

In which version of C# Indexers were introduced?

In which version of C# or .Net Framework Indexers were introduced ?
Jon Skeet
people
quotationmark

They've always been in C# and .NET, right from version 1.0. more 11/18/2017 8:52:02 AM

people