Browsing 7239 questions and answers with Jon Skeet

error when tried to delete empty rows from datatable

I tried this LINQ code to delete empty rows from datatable NewDt = NewDt.Rows.Cast(Of DataRow)(). Where(Function(row) Not row.ItemArray.All(Function(field)...
Jon Skeet
people
quotationmark

Yes - read the error message. You've already got a variable called row in your method, so you need to choose a different name for the parameter in the lambda expression. For example: NewDt = NewDt.Rows.Cast(Of DataRow)(). ... more 3/14/2014 7:04:55 AM

people

how to convert different number systems to base ten in the simplest way

I have searched for this question on the website but do not understand most of the solutions posted. my question is; i have a method: public static int convertToDecimal(int...
Jon Skeet
people
quotationmark

An integer value itself (e.g. an int) doesn't have a base, really. It's just a number. Bases are mostly important for textual representations. (They're also important in floating point numbers as that determines what sort of point is... more 3/14/2014 6:58:35 AM

people

String to XMLGregorianCalendar issue

i am trying to convert from string to XML Gregorian Calendar date and its always returning me a new instance, Please check my code below Input date ::2014-03-13 15:34:33...
Jon Skeet
people
quotationmark

See below for why the existing code isn't working for you, and a workaround. However, to preserve the UTC offset and do the whole thing far more simply, I suspect you just want to use DatatypeFactory.newXMLGregorianCalendar(String): //... more 3/13/2014 3:53:34 PM

people

"R" is not regestering as Equal to "R" when send over TCP connection

I am trying to have a client send a command to my service, that command being "R". But when I try to make an IF statement it will not register the "R" that came in via TCP as...
Jon Skeet
people
quotationmark

Aside from the vast number of pointless comparisons you're making, the first problem is that you're ignoring the result of Stream.Read... and instead creating a string out of the whole 1024 bytes within message. If you change it to: int... more 3/13/2014 3:19:01 PM

people

A field initializer cannot reference the nonstatic field method or property error in c#

When I run the windows form application it shows initializer cannot reference the nonstatic field method or property. string lia =...
Jon Skeet
people
quotationmark

I thin, it can not recognize lia as string. No, it's recognizing it just fine - but as the error says, you can't use the value of one instance variable within the initializer for another. The simplest fix is usually to put the... more 3/13/2014 12:54:29 PM

people

Test whether a method returns doubles

Here is a paraphrasing of a question I posed to a group of students, and it turns out that finding an answer is a bit trickier (for me, anyway) than I expected: Suppose you have...
Jon Skeet
people
quotationmark

Reflection is the best fit here in general (it's a pretty unusual requirement) but something else that would at least work would be to use overload resolution: provide alternative methods with a parameter of float, long and Double, but... more 3/13/2014 11:41:54 AM

people

Access to protected member and properties case

I have one base class called Cocpit for Server and Protocl derived classes then I have Heartbeatsupervisorclass which would take Server and protocol and do some work anyway I got...
Jon Skeet
people
quotationmark

and after all when want to use inside Heartbeate I cant access protocol.Name inside constructor - how to access that? You can't, while it's protected. protected is designed to give access to protected members of objects of type Foo... more 3/13/2014 9:47:08 AM

people

Why do I can't use more than one Java increment or decrement operators?

I am so suprise when I using two Java increment operators at the same time.Please check below codes.. public class Testing { public static void main(String... str) { int...
Jon Skeet
people
quotationmark

The result of ++x or x++ is categorized as a value, not a variable - and both operators will only work on variables. For example, from section 15.14.2 of the JLS: A postfix expression followed by a ++ operator is a postfix increment... more 3/13/2014 8:13:42 AM

people

using covariance on an interface ...Runtime Error Unable to cast object of type 'derviedAService ' to type 'iBaseService`1[mybase]'

using System; using System.Collections.Generic; namespace mymodels { public abstract class mybase { public string v1 {get; set;} } public class derivedA :...
Jon Skeet
people
quotationmark

Your interface isn't covariant - it needs to be explicitly covariant when you declare it. So this: interface iBaseService<T> where T : mymodels.mybase should be: interface iBaseService<out T> where T :... more 3/12/2014 5:22:34 PM

people

Implementation of Hashmap

I am not sure if it's been asked. I am fairly new to hashtables and was wondering about something about the inner class. I was looking at the hashtable API and it had: static...
Jon Skeet
people
quotationmark

Well that would be a valid nested class, but it wouldn't implement Map.Entry, so it couldn't be used for the Map methods which require Map.Entry, such as entrySet(). The reason it's declared with the static modifier is that a... more 3/12/2014 5:18:28 PM

people