Browsing 7239 questions and answers with Jon Skeet

Strange error when declaring a variable in C# using VS13

So I have the office library imported, I say using Microsoft.Office.Interop; I am trying to create a method that checks to see if an Excel workbook is open. Havent made any...
Jon Skeet
people
quotationmark

using directives don't work like that. You can't provide part of a namespace name in the using directive, and then the rest elsewhere. From section 9.4.2 of the C# 5 specification: A using-namespace-directive imports the types... more 4/2/2014 2:16:58 PM

people

Java Error Actual and formal argument lists differ in length

I am trying to call a method, but it is giving this error: java:112: error: required: String, String found: String reason: actual and formal arguments lists...
Jon Skeet
people
quotationmark

Well it's quite simple. Here's the declaration of setShippingDest: public void setShippingDest(String inCustName, String inDestn) And here's how you're trying to call it: shipOrder.setShippingDest("Broome"); You've provided one... more 4/2/2014 1:49:39 PM

people

Why Java compiler as distributed as executable and not as JVM bytecode?

In the answer Platform independence in Java ByteCode, it is said that Java Compiler is same across all the platforms. I do understand that. My question is that why Java compiler...
Jon Skeet
people
quotationmark

javac.exe (on my installation, JDK 1.8 on Windows x64) is about 15K in size. This isn't the full compiler. The compiler itself really is written in Java, and javac.exe is just a launcher, effectively. This is true of many of the tools that... more 4/2/2014 9:34:05 AM

people

Casting in foreach loop

I ran into the following code: foreach (var row in datatable.Rows.Cast<DataRow>()) { some code here } Now, I think casting in a foreach loop is incorrect, since I think...
Jon Skeet
people
quotationmark

Well it calls Cast<DataRow> once, but that will actually cast each item as it's fetched. So there is a cast on each iteration (at least potentially; Cast has an optimization when it knows it's not necessary) but there's only a single... more 4/2/2014 8:39:45 AM

people

how to add ascii character in listview?

I want to add ascii char in my listview. Here is my code: ListViewItem item = new ListViewItem(); item.Text =...
Jon Skeet
people
quotationmark

195 is not in the ASCII range. Unfortunately there are many sites around which show "ASCII tables" containing characters over 127. These are often called "extended ASCII" - often with a false implication that there's only one such... more 4/2/2014 7:16:52 AM

people

delegate can be used as class type

I have example code of delegate in c#. I wan to know can delegate be used as class as the it is shown in the following example: using System; // This delegate returns int and...
Jon Skeet
people
quotationmark

Yes, delegate types are classes - each concrete delegate type inherits from MulticastDelegate, and you can pass around delegate references just like you can pass any other kind of reference. There are various ways in which they're handled... more 4/1/2014 7:19:38 PM

people

How to add item to dictionary "Parallel loop safe"

I have a Parallel.ForEach loop doing some treatment. But the first operation is to add a value in the dictionary if the key is not contained. I get an error when adding it, it...
Jon Skeet
people
quotationmark

Even aside from your race condition, Dictionary<,> isn't thread-safe. You should be using ConcurrentDictionary<,> and in this case probably the AddOrUpdate method to perform the modification atomically. (I assume that you want... more 4/1/2014 3:40:22 PM

people

bootstrap datetimepicker today dd/MM/yyyy

With the eternicode bootstrap-datetimepicker today uses MM/dd/yyyy. How do I set datetimepicker to use dd/MM/yyyyy so that it highlights today correctly? E.g. today is the 1st...
Jon Skeet
people
quotationmark

As per the documentation, just set the format property. See the configuration section for different ways of setting options. For example (using datetimepicker instead of datepicker): $('.datetimepicker').datetimepicker({ format:... more 4/1/2014 3:36:44 PM

people

Convert a number and accept any decimal separator

I have a double number 0,401780062641746 I want to format it to 0.40178006 I'm using this code: string.Format("{0:0.00000000%}", dNum); But the result is 40.17800626 I want...
Jon Skeet
people
quotationmark

If you only need to cope with decimal points, so you don't need to handle grouping separators, the simplest option would be to just replace any commas with dots: string input = ...; input = input.Replace(',', '.'); double value; if... more 4/1/2014 3:25:34 PM

people

Unable to compile java class file in cmd

I am in c:\new\control folder and want to execute c:\hello.java I am trying c:\new\control> javac c:\hello.java Its creating class file but c:\new\control> java hello is...
Jon Skeet
people
quotationmark

By default, the .class file will be generated alongside the .java file. Options: Use -d . when compiling to generate the classes relative to the current directory (including creating subdirectories for packages): > javac -d .... more 4/1/2014 2:22:38 PM

people