Browsing 15980 questions and answers with Jon Skeet

C# json parse string inside 2nd curly brackets {X{Y}}

I try to parse string inside 2nd curly brackets using C# / json String looks like this: {"R27":{"DEVX":0.1346224}} My aim is read value of DEVX, which is 0.1346224 I've...
Jon Skeet
people
quotationmark

Yes, absolutely - assuming you know the two names involved, you can just index twice, once to get the object for R27, then once within that object to get the value of DEVX: using System; using Newtonsoft.Json.Linq; public class Test { ... more 12/3/2017 8:47:46 AM

people

throw null in decompiled ArraySegment

I've just had a look at the ArraySegment class in .NET Core (...\microsoft.netcore.app\2.0.0\ref\netcoreapp2.0\System.Runtime.dll). Every method\property just has throw null in...
Jon Skeet
people
quotationmark

You're looking at the reference assemblies. That's not the real implementation - it's just a placeholder to compile against, effectively. You'll see the assembly only has the public/protected members, and every code-based member... more 12/1/2017 11:42:45 AM

people

Google Cloud Speech streaming in the Unity Game Engine

I would like to know if anyone has been succesful with implementing Google Cloud Speech (streaming) into the Unity Game Engine? It would be wonderful if Google's Speech technology...
Jon Skeet
people
quotationmark

No, streaming in Google Cloud Speech API requires gRPC, and gRPC isn't supported in Unity at the moment. Once gRPC is supported, I'd expect the client library to port very easily - or just work out of the box, potentially. Supporting gRPC... more 12/1/2017 10:35:21 AM

people

Disagreement about string is a primitive type

As you know, MSDN library says that string, decimal and object are not primitive types. I'm sharing a quote about this: The primitive types are Boolean, Byte, SByte, Int16,...
Jon Skeet
people
quotationmark

I wouldn't personally call dynamic, decimal, object or string primitive types. I'd use Type.IsPrimitive for the canonical source there. Note that dynamic isn't even a type in the CLR sense. The C# 5 MS specification only uses the word... more 12/1/2017 8:57:24 AM

people

Error message "CS5001 Program does not contain a static 'Main' method suitable for an entry point"

Unable to execute the following code error CS5001 Program does not contain a static 'Main' method suitable for an entry point What does this error message mean? class...
Jon Skeet
people
quotationmark

It means that you don't have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project... more 12/1/2017 7:28:54 AM

people

LINQ is converting string to special characters

I am using this query to get data from database. string nfc = "53f8372c"; var temp = db.tempTable.AsNoTracking().Where( x => ...
Jon Skeet
people
quotationmark

That's just parameterizing the SQL. If you look at the parameters passed to the query, you'll see that :p__linq__0 has a value of 53f8372c. This parameterization is helpful, as the server can cache the query plan and reuse it for the same... more 11/30/2017 6:15:27 PM

people

Let current thread finish using the function before letting other threads call it C#

I can't seem to get thread.Join() to work for this example. I'm new to multithreading and C# so I am kind of unsure how to apply the online examples into my own coding. Here's an...
Jon Skeet
people
quotationmark

It sounds like you just want a lock, using a static field for an object whose monitor you lock on: private static readonly object lockForSharedMethod = new object(); ... private static void SharedMethod() { lock(lockForSharedMethod) ... more 11/30/2017 7:10:11 AM

people

The type T must be a reference type in order to use it as parameter while using interface

I got the error for the below code public static Moq.Mock<T> CreateInstanceOfIMock<T>() { return new Moq.Mock<T>(); } I have solved the error it by using...
Jon Skeet
people
quotationmark

There's no generic constraint in C# to enforce that a type argument is an interface. But where T : class is really "where T is a reference type" - it includes interfaces. If you wanted to enforce that T is an interface rather than a... more 11/30/2017 7:04:57 AM

people

why folder structure is not created even though I had taken package statement?

I was trying a package concept in java. I created a Test.java file that only contains a single statement: package pack1; When I compile the file using the command as: javac...
Jon Skeet
people
quotationmark

In your original code, you haven't declared any classes - so there wouldn't be any class files. If there are no class files, presumably the compiler sees no need to create the directory structure that would have been necessary for any... more 11/29/2017 11:17:24 AM

people

Why is this class not considered a supertype as a parameter?

Given the following example, why am I able to override the return type List<? extends IConfigUser> as List<ConfigUser> in getUserList() but cannot do the same for the...
Jon Skeet
people
quotationmark

You can return a more specific type in an override, but you can't require that you accept a more specific type. Get rid of the generics, and you can override a method returning Object with a method returning String, but you can't override... more 11/29/2017 11:09:57 AM

people