You searched for how does c# work. We found 81 results in 0.185 seconds.

How to parse a angular ui dateTime string to c# datetime

I know a lot of questions about this has been answered. I have tried for about 3 hours with no luck. I am using angular-ui datetime picker, the format is ...
Jon Skeet
people
quotationmark

Look at the format you're passing: "yyyy-MM-dd'T'HH:mm:ss'Z'" That has no milliseconds, whereas your sample is "2015-02-08T06:00:00.000Z" which does have milliseconds. It looks like you want: "yyyy-MM-dd'T'HH:mm:ss.fff'Z'" Also, I'd... more

people

How to remove escape extra slash in java properties

I am using the following to write some values to a .properties file. this code works with one small problem the value that gets written is like...
Jon Skeet
people
quotationmark

That's fine. That's how it's meant to be written to the properties file. From the Properties.store documentation: The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly... more

people

C# `foreach` behaviour — Clarification?

I've read Eric's article here about foreach enumeration and about the different scenarios where foreach can work In order to prevent the old C# version to do boxing , the C# team...
Jon Skeet
people
quotationmark

MyEnumerator does not has the required public methods Yes it does - or rather, it would if Current were public. All that's required is that it has: A public, readable Current property A public MoveNext() method with no type... more

people

Why does my second variable value change when updating the first?

I have a Form with two Datalog class variables public partial class ModifyDataForm : Form { public DataLog DLog; private DataLog copyCurrent; public...
Jon Skeet
people
quotationmark

The value of copyCurrent doesn't change. The data within the object that copyCurrent refers to may change, but that's a different matter. Suppose you give two separate people (Alice and Bob) pieces of paper with your home address written... more

people

How to check and see if a number contains a decimal?

I'm trying to create a pretty basic calculator application. I'm running into a problem with decimals. I'm pretty new to C#, so I don't really know what to do here. When I click on...
Jon Skeet
people
quotationmark

Well it sounds like you're actually wanting to test whether a string already contains a decimal point - not a number. Assuming you're not trying to internationalize this, you probably just want: if (textBox.Text.Contains(".")) { //... more

people

How do I make a member visible to its subclasses (which might not be in the same package)?

I have an abstract base class with certain fields/abstract methods in it. How do I make these visible to its children, even if the children don't live in the same package? (And I...
Jon Skeet
people
quotationmark

Normaly, you would just use protected, which does work within subclasses within the restrictions in the JLS: In foo/Parent.java: package foo; public class Parent { protected int x; } In bar/Child.java: package bar; import... more

people

C# method return versus variable in a lambda

So I was fighting some LINQ (entity framework) lambda which I ultimately fixed by storing the result in a variable. Something like: IQueryable<object> DoStuff() { return /*...
Jon Skeet
people
quotationmark

Sure - it's a matter of understanding what happens to the lambda expression. For LINQ to SQL, EF etc, it's converted into an expression tree - basically data that represents the code in the lambda expression. The LINQ provider then has to... more

people

C#, Using self as a parameter for an abstract override method of the base class

How would I override DerivedZ() in the child, without having to specify a U in the base class? The latter solution appears a bit excessive. public abstract class Z {} public...
Jon Skeet
people
quotationmark

You can't use the first form, because it's not properly overriding the method. If you could do that, imagine this code: public class C : A<DerivedZ> {} A<DerivedZ> x = new B(); x.GetZ(new C()); That should work fine, after... more

people

When can C# infer the type of a parameter?

Why does the following correctly infer the type of T: void foo<T>(IEnumerable<T> src){ src.Select(id => id); } But this doesn't: Func<T, T>...
Jon Skeet
people
quotationmark

Type argument inference always works on method arguments - including the first argument to an extension method like Select. So your second call is effectively: Enumerable.Select(new List<int>(), Id()) Select will be able to use... more

people

C# explicit cast from collection of KeyValuerPair to Dictionary

I have a list of KeyValuePairs. I normally would use ToDictionary. However I just noted that the error message (shown below) has something about explicit cast, which implies I...
Jon Skeet
people
quotationmark

Implies I can actually cast list to dictionary Well, it implies that the cast would be valid at compile-time. It doesn't mean it will work at execution time. It's possible that this code could... more

people