Browsing 7239 questions and answers with Jon Skeet

How to add to the datelist? it's overwrite. How can I solve it?

How to add to the date list? it's overwrite. How can I solve it? List<LeaveDetails> leaveList=leaveDetailsService.getleavedatetesting(3); List<Date> datelist =...
Jon Skeet
people
quotationmark

Look at this loop: for (int i = startd.getDate() ; i<=(endd.getDate()+1);i++){ startd.setDate(i); datelist.add(startd); System.out.println(i+"--datelist ---> "+datelist.toString()); } You're adding... more 12/15/2015 7:06:47 AM

people

Is method overloading polymorphism Early Bound in C#?

In C#, if I have public class BaseClass { //BaseClass implementation } public class Derived : BaseClass { //Derived implementation } public class AnotherClass { ...
Jon Skeet
people
quotationmark

The binding time in C# depends on whether the binding involves dynamic or not. As you've seen, if you use dynamic you get execution-time overload resolution; if you don't, you get compile-time overload resolution. Note that even when... more 12/14/2015 3:51:32 PM

people

Associativity of operators

In the C# specification is said: Except for the assignment operators and the null coalescing operator, all binary operators are left-associative, meaning that operations...
Jon Skeet
people
quotationmark

There's no problem here, because all the non-primary unary operators have the same precedence as each other, and a different precedence to all binary operators. Associativity comes into effect when an operand is between two operators of... more 12/14/2015 1:15:33 PM

people

Can't cast to generic type c#

I have the following scenario public class A { } public class BA : A { } //other subtypes of A are defined public class AFactory { public T Create<T>() where T :...
Jon Skeet
people
quotationmark

Well the cast could easily fail. Suppose I have: public class AB : A {} B b = new B(); AB ab = b.Create<AB>(); That would end up trying to assign a B reference to a variable of type AB. Those are incompatible. It sounds like you... more 12/14/2015 1:10:33 PM

people

Use Flags Enum as a normal Enum

Is there a way to optionally force a [Flags] enum to be "non-Flags" for specific uses? For example, say I have enum MyEnum { X , Y , Z } Now let's say I...
Jon Skeet
people
quotationmark

Fundamentally, each enum type either is designed to have be a bit mask, or isn't. Options you might consider: Two separate enums, as per your code One non-flags enum, but make A.Property a List<MyEnum> or similar One flags enum,... more 12/14/2015 1:09:15 PM

people

c# access elements of list passed as object type

I want to access members of lists passed in as "object" (the function is handling other data types such as arrays as well). Unfortunately, while this works: List<object>...
Jon Skeet
people
quotationmark

No, a List<string> isn't a List<object>... although it is an IEnumerable<object> due to generic covariance. However, a List<int> isn't even an IEnumerable<object> as covariance doesn't apply to value type type... more 12/14/2015 7:13:53 AM

people

How to pass command line arguments in kubernetes?

Need to pass command line arguments for the docker containers appContainer1 & appContainer2 in the pod.yaml. pod.yaml apiVersion: v1 kind: Pod metadata: name:...
Jon Skeet
people
quotationmark

It sounds like you don't actually want command line arguments, but environment variables - and you can use env for that: - name: appContainer1 image: gcr.io/mybucket/appContainerImage1 ports: - containerPort: 8080 env: -... more 12/12/2015 10:33:45 AM

people

Console.ReadLine in async method isn't blocking progression..?

I need to know if there's a way to execute DownloadPage(result) without immediately proceeding to Console.ReadKey() in my main method. What's happening is that DownloadPage...
Jon Skeet
people
quotationmark

Well yes - you're not waiting for the async operation to actually finish. You should declare the method to return Task instead, like this: static async Task GetPageHtml(string _url) and then wait for it in your Main... more 12/12/2015 9:38:45 AM

people

copy list into other list

I know this is asked many times and i am trying to implement same . I have list below internal class GenList { public string Col1 { set; get; } public string Col2 { set;...
Jon Skeet
people
quotationmark

dont want content to change in cloned list if something is changed in main list. That sounds like you want a deep clone, basically. In other words, creating a new list where each element is a copy of an element in the original list,... more 12/11/2015 7:58:17 PM

people

Nullable Int in LINQ with outer join

I have the following LINQ query var categories = (from c in context.Categories join pc in context.ProductCategories on new { Id =...
Jon Skeet
people
quotationmark

This gives me a compiler warning at pc.CategoryId == null saying it will always be false as CategoryId is not nullable. But because of left outer join it comes as null from database. No, pc might be null - but pc.CategoryId would... more 12/11/2015 7:45:10 PM

people