Browsing 15485 questions and answers with Jon Skeet

Sentiment analysis through google cloud Library

Now a days i am implementing sentiment analysis through google cloud library,my code is string text = "Feeling Not Well"; var client = LanguageServiceClient.Create(); var...
Jon Skeet
people
quotationmark

You can either use gcloud auth application-default login from the command line (assuming you have the Cloud SDK installed), or generate and download a service account JSON file and then set the GOOGLE_APPLICATION_CREDENTIALS environment... more 12/31/2016 11:16:21 AM

people

Enqueue various method calls with parameters

For a game in which you have to code your own AI, I need to enqueue various method calls with parameters. For example: MessageReceived(string text, Source...
Jon Skeet
people
quotationmark

It outputs 5 five times because by the time you're executing the actions, i is 5. There's only a single i variable, and its lifetime is extended until all anonymous functions that have captured it are eligible for garbage collection. To... more 12/31/2016 10:48:04 AM

people

How to solve "The type or namespace name 'Systems' does not exist in the namespace 'Fizzler'"?

So I used Nuget to get the Fizzler package and it brought down the HTML agility pack, but now I have a compilation error when trying to use the library The type or namespace name...
Jon Skeet
people
quotationmark

Despite your comment, it looks like you need the Fizzler.System.HtmlAgilityPack package. You should then be able to use: using Fizzler.System.HtmlAgilityPack; ... at which point the extension methods in HtmlNodeSelection (including... more 12/29/2016 6:47:12 PM

people

c# restrict methods to other methods

I have a class that contains several methods eg.: class mySqlTool{ private string _values, _table, _condition, _result; public mySqlTool Select(string values = null){ ...
Jon Skeet
people
quotationmark

General description - see end for specific comments Is this what I want even possible? Not within the same class, no. How would the compiler know what you'd already called? (Imagine you had a method with a parameter of type Test -... more 12/29/2016 11:38:12 AM

people

how to fix the error on the Round, what should i change the line to?

public void ChangeTexts(long length, int position, int percent, double speed) { Label3.Text = "File Size: " + Math.Round((length / 1024), 2) + "...
Jon Skeet
people
quotationmark

You're currently dividing by 1024 in integer arithmetic and then rounding the result. In other words, you're rounding something that's already an integer - not really useful. The simplest fix is to divide by 1024.0 instead, to make it... more 12/29/2016 10:47:49 AM

people

Reusing of survived local variable in each call. UB?

I'm new in C#. I encountered such code-example: namespace App1 { delegate int Sum(int number); class TestAnonymusMethod { static Sum m() { ...
Jon Skeet
people
quotationmark

Is it "undefined behavior"? No, it's well-defined behaviour - just not the behaviour you expect. Looks like it happens because of when scope of result is closed, its life time is undefined. Nope, the lifetime of result is... more 12/28/2016 12:05:57 PM

people

What is wrong in code to

It's making me little hard to understand the actual behavior in this scenario. What is actually happening to not executing the task when it should but later when SemaphoreSlim is...
Jon Skeet
people
quotationmark

The problem is your using statement. This is how things are happening: Create semaphore Start tasks running in the background Dispose of semaphore Tasks try to use semaphore... but can't, because it's disposed Options: Just remove... more 12/28/2016 10:54:04 AM

people

C# for loop and post increment

I'm having a hard time understanding why the following loop prints 0 on each iteration. for (int i = 0, j = 0; i < 10; i++) { Console.WriteLine(j += j++); } Shouldn't...
Jon Skeet
people
quotationmark

Shouldn't the value of j increase after each iteration? Nope. Your loop body is somewhat equivalent to this: int tmp1 = j; // Evaluate LHS of += int tmp2 = j; // Result of j++ is the value *before* the increment j++; j = tmp1 +... more 12/26/2016 9:25:03 PM

people

How do i refer to an object inside a method that it has invoked?

I've created a class named Rational which stores two private ints (numer and denom). I am trying to create a method that returns a new Rational object that contains the reciprocal...
Jon Skeet
people
quotationmark

It's not clear what rat1 is meant to be in your reciprocal method... but the reason you can't just use this(...) is that these are methods, not constructors. It looks to me like you probably want: public Rational reciprocal() { return... more 12/26/2016 8:28:08 PM

people

C# User class. GetHashCode implementation

I have simple class only with public string properties. public class SimpleClass { public string Field1 {get; set;} public string Field2 {get; set;} public string...
Jon Skeet
people
quotationmark

The contract for GetHashCode requires (emphasis mine): The GetHashCode method for an object must consistently return the same hash code as long as there is no modification to the object state that determines the return value of the... more 12/24/2016 11:44:49 AM

people