C# vs. Java: generics covariance and contravariance [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Both C# and java implement generics covariance and contravariance, but in a quite different manner: C# restricts co- and contra-variance to generics interfaces, Java enables it to any generics class or method.
What are exactly the differences regarding to the syntax?
What kind of code is possible in one language that is not possible in the other language?
What are the practical limitations due to the lack of integration in their respective framework (i.e. missing implementation of default collection)?
Thank you in advance!

Related

How does C# lay out data? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am a new user of C# (for work), coming from C++ development. I'm used to knowing more or less how data is laid out, and how many levels of pointer indirection there are, as these things can be very important for performance.
I know I'm supposed to just relax and have a good time hammering out business software and not think about these details on the clock, but is there good documentation for this for C# somewhere?
I know there is compilation to IR, and then JIT to native code, so I guess I am asking about how C# source relates to the native x86-64 code.

Why payment gateways are only designed in Java language? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I have been talking with one java programmer and he told me that all of the Payment Gateways are designed in Java because they are secure in comparison of any .net based language.
Is it true?
No, that is not correct. .NET based languages and Java can each be programmed securely, or insecurely.
Given the large number of high profile Java vulnerabilities which have surfaced over the years, I highly doubt the quality of the statement made by "one java programmer". This smells more of FUD spreading than any kind of factual statement.

Why do Lambda expressions in Java 8 implement a functional interface, instead of a delegate as in C#? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Many developers who work on projects in Java and on other projects in C# are used to the C# delegate syntax.
Also, the C# delegate syntax is much shorter than the Java functional interface syntax:
Example in C#:
public delegate void ProcessBook(Book book);
Same example in Java:
public interface ProcessBook {
void processBook(Book book);
}
As C# has in the past adopted much of the Java syntax, why did we not adopt this C# delegate syntax in Java 8?
probably because of backward compatibility. when you use interface, you can use it with all the existing api (and java's strength is the plenty of libraries). for example you can use lambda in every place instead of Runnable, Comparable etc. But when you create some new concept / new keyword, all existing libraries can't benefit from it - they have to be rewritten to work with this new construct

C# classes interoperate with other .NET languages [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Is there a way to ensure that other .NET languages will interoperate with my C# classes ?
The most important thing would be for you to use the CLSCompliantAttribute. This prevents you from inadvertently using non CLS compliant features in C#.
There are a few pretty obvious rules that I can mention here. Note, this list is not exhaustive. I just wanted to point our some of the rules to give you a feel of what CLS compliance is all about.
Do not use unsafe types (pointers) in the public interface.
Do not mix member name casing in the public interface.
Do not use unsigned types in the public interface.
Read the article Cross Language Interoperability for more information.
Yes, decorate your assembly with CLSCompliant attribute.
Making your code CLS Compliant

Visual Basic libraries on C# code [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Is it incorrect or frowned up to use Visual Basic libraries on C# code?
One particular example is the CSV parser which exists for VB but not for C#.
using Microsoft.VisualBasic.FileIO for TextFieldParser
I am sure there is other examples. Of course there are ways to do the same in C# but would require writing more code, why reinvent the wheel?
The whole point of .NET (well, one major point) is that it doesn't matter what language things are written in! So calling a VB library from C# is no big deal.
TextFieldParser is perfectly safe and reasonable to use from C#. It's part of the default Framework install. Use it!
"Why reinvent the wheel?" -- Exactly!

Categories