Browsing 7239 questions and answers with Jon Skeet

So a VB interface can't have shared functions. Is there an alternative to creating dummy objects?

To avoid getting into the weeds on my particular program, let me just create a simplified case. I have a generic class that should work on a variety of objects. Each of those...
Jon Skeet
people
quotationmark

There's no really simple way of fixing this, no. Depending on what thing_name does, however, you might approach things in a different way. If each implementation just returns a constant value, then it's effectively metadata about the... more 5/29/2015 3:42:17 PM

people

Where is the obj folder of my visual studio 2010 project

I am new to Visual Studio. I am using VS 2010 and I cannot find the main method of my C# application. After browsing a bit, I found out that it is created during the compilation...
Jon Skeet
people
quotationmark

I cannot find the main method of my C# application A web site doesn't have a "main" method. It usually has global initialization hooks, but nothing quite like Main. It also looks like you've created a "Web Site" project rather than a... more 5/28/2015 5:05:46 AM

people

JSON.NET: Deserializing from JSON with LINQ

I have following json: {[ "{\"Id\":3,\"ParentName\":\"TicketController\",\"ChildName\":null,\"Body\":\"Ticket\",\"ParentId\":null,\"HasChildren\":true,\"imageUrl\":null}", ...
Jon Skeet
people
quotationmark

Each element in your array is just another string - so you need to parse each of those as well. For example: IList<Page> pages = jsonArray .Select(text => JObject.Parse(text)) .Select(p => new Page { ... }) ... more 5/26/2015 12:00:39 PM

people

How to load the name of argument based on another argument in development time?

I have a function like this: public static int WriteLog(string messageCode, params string[] parameters) { ///do some operation here } Based on the first argument(messageCode)...
Jon Skeet
people
quotationmark

You can't do that. There's simply no way of representing that in C# with your current approach. What you could do is have a bunch of classes each with a WriteLog method, in a sort sort of pattern which emulates Java enums to some extent.... more 5/26/2015 7:21:22 AM

people

Is storing personal libraries as console applications a bad idea?

I've started making my default library type a console application. The immediate benefit is that I can easily implement integration tests within the main application. Is there a...
Jon Skeet
people
quotationmark

The immediate benefit is that I can easily implement integration tests within the main application. Why would you want to do that? I don't see that as a benefit at all. Why would you want to deploy your tests when you deploy your... more 5/25/2015 10:32:39 AM

people

How to catch the returned object from another process in C#

I have a c# program that will call another c# program using Process.start() that I also have the source code. How I can return a string for example from the second program that...
Jon Skeet
people
quotationmark

The simplest way would probably be to write it to the standard output (i.e. the console) of the "child" process. The "parent" process can then read the standard output (and error) of that process. See... more 5/25/2015 10:28:53 AM

people

Create a RESTful service with 3 similar Get methods

I want to create a REStful web service. This service returns "Meetings" for a certain day, week or months. I would create 3 Get methods which takes date values determined by...
Jon Skeet
people
quotationmark

I wouldn't think of it in terms of the method names - I'd think of it in terms of the URLs to start with: /api/meetings?date=... /api/meetings?startDate=...&endDate=... Think of it as a collection of meetings, and the query... more 5/25/2015 10:14:25 AM

people

How can I have an out ViewData Parameter?

I have some repetitive ViewData data that I need them in several controllers. I'd like to create a utility function for that. I'm trying to have an out parameter and call the...
Jon Skeet
people
quotationmark

You're getting an error because an out parameter has to be initialized in the method before you use it - it's initially unassigned. However, I don't think you want it to be an out parameter at all. You can just pass the existing reference... more 5/25/2015 7:25:44 AM

people

Which Map class should I use for data consisting of different types?

It seems that HashMap is limited to only one value, and I need a table of values like: Joe(string) 25(Integer) 2.0(Double) Steve(string) 41(Integer) 1.6(Double) etc. I...
Jon Skeet
people
quotationmark

It sounds like you should be creating a separate class with a String field, an int field and a double field. Then you can create a map with that as the value type, and whatever type you like as a key. For example: Map<String,... more 5/25/2015 7:21:12 AM

people

Why does it wants the method to be static?

I am building my first game, relying heavily on various tutorials and guides on the Java website, and I have come across a problem. In my game engine, I want to call the...
Jon Skeet
people
quotationmark

Look at your method call: Player.update(); That's calling it as if it's a static method - on the type, rather than on an instance of the type. Which player do you want to update? You don't seem to have any instances of it... you should... more 5/23/2015 7:44:45 PM

people