Browsing 15485 questions and answers with Jon Skeet

Class Access Modifiers internal

I have created a class called ClientCapsule which contains data about the client, this class contains another class i created in the same scope called ClientInformation . i don't...
Jon Skeet
people
quotationmark

It sounds like you need ClientInformation to be a public class - just give it an internal constructor, preventing instantiation from elsewhere. more 1/26/2017 10:03:59 PM

people

Scope of members inside using statement

I'm confused by the following code and the scope of using statement and its object disposal. using(DbFactory db = new DbFactory()) { Repository repo = new...
Jon Skeet
people
quotationmark

The scope of the repo variable (in your first case) is the using statement. You can't refer to it outside the using statement, because it's declared in there. We can't tell the scope of the result variable because you haven't shown its... more 1/25/2017 6:01:12 PM

people

Why does (boolean ^ int > 0) work?

When you try to do something like this: if (true ^ 1) { //do something } the compiler reasonably says that operator ^ is not defined for argument types boolean and int. But...
Jon Skeet
people
quotationmark

It's simple: > has higher precedence than ^, so if (true ^ 1 > 0) { is equivalent to if (true ^ (1 > 0)) { which is equivalent to if (true ^ true) ... which is just logical XOR. I would never write code like this, mind... more 1/25/2017 2:55:27 PM

people

HttpWebRequest not posting

As per the question, I POST json to http but I'm not getting any output when I use GET. I'm trying to POST json then close the stream. I do not need to care about the reply. To...
Jon Skeet
people
quotationmark

You're never asking for a response, so it's not making the request. Just add: using (var response = request.GetResponse()) { // Use the response } Note that your "get" code isn't exception-safe - it should use using statements... more 1/25/2017 9:12:51 AM

people

Unexpected type error Simple hangman code

I'm building a very simple hangman game. where it takes in a word to be guessed then takes in letters as guesses. But i am getting an unexpected type error. The error is occuring...
Jon Skeet
people
quotationmark

The left-hand side of an assignment has to be a variable - you've got a method call. Note that strings are immutable, so assuming you were trying to change the content of secret, you can't. You might want to create a char[] from secret,... more 1/24/2017 3:18:13 PM

people

dotnet restore unable to resolve Telerik.UI.for.AspNet on macOS

I'm trying to get a dotnet project working on macOS but I'm getting stuck when I run dotnet restore. All packages install fine except for my Telerik package: Unable to resolve...
Jon Skeet
people
quotationmark

Well that's not the name of a Nuget package any more, as far as I can tell. I believe you want the KendoUICore. Based on the versions of that - which include 2016.3.1118 - I suspect that temporarily had the name... more 1/24/2017 8:20:56 AM

people

UTF 8 not working in live server

I am new to docx4j. I am creating new .docx file using docx4j. My code works perfectly while deploying project from eclipse to tomcat server. But it does not work on live server....
Jon Skeet
people
quotationmark

I suspect this may be the problem: afiPart.setBinaryData(html.getBytes()); That will use the platform-default encoding - which could clearly differ between your local machine and your server. I would strongly encourage you to always... more 1/23/2017 11:13:26 AM

people

Empty catch but exception is still thrown

Have a look at the following source code private IEnumerable<string> GetAntivirusSoftwareFromNamespace(string @namespace) { try { var...
Jon Skeet
people
quotationmark

The exception isn't thrown within the method you've shown - you're basically returning a query to the caller, and that query is then failing. One option would be to force the query to execute immediately by calling ToList(). That way, any... more 1/22/2017 5:48:29 PM

people

How to convert a string into Int collection

Below is my string. var str = "1,2,3,4,5"; var strArr = str.split(","); // this gives me an array of type string List<int> intCol = new List<int>(); //I want...
Jon Skeet
people
quotationmark

Well that's a way of doing it, certainly - but LINQ makes it a lot easier, as this is precisely the kind of thing it's designed for. You want a pipeline that: Splits the original string into substrings Converts each string into an... more 1/22/2017 9:28:24 AM

people

i am getting an error Argument 2 may not be passed with ref keyword while using ado.net

int? t = 0; cmd.Parameters.AddWithValue("@Res", ref t); I get an error in the second line: argument 2 may not be passed with ref keyword.
Jon Skeet
people
quotationmark

You can only pass an argument by reference with ref if the parameter is a ref parameter as well. AddWithValue doesn't have any ref parameters, so you can't use it that way. Note that you have to specify ref when calling a method if a... more 1/21/2017 9:33:46 AM

people