Hi all,
I have some questions regarding C#. I come from a Java background. I am
using .NET 1.1. Please limit your answers to v 1.1, otherwise please state
the version to which it applies to.
1) I have seen code like this:
public void someMethod() {
// code
MyObject otherVar;
using (SomeClass var = DifferentClass.method()) {
otherVar = someOtherObject.method();
}
}
What is happening here? What is the part that begins with "using"? And what
is the purpose of putting that whole thing inside the "using"? Why not just:
MyObject otherVar = someOtherObject.method();
2) What are delegates, how are they used, and why would you use them? Can
you provide a simple example?
3) Are there inner classes? In Java, it's a class defined within another
class, which may or may not be accessible outside of the class.
For example:
public class A {
public static class B {
public void methodInB() { ... }
}
}
B can be instantiated by : A.B b = new A.B();
4) Are there anonymous inner classes?
For example:
public class A {
public void methodInA() {
var.addActionListener() { new ActionListener() {
public void actionPerformed(Object a) {
}
}
}
}
The inner anonymous class is the new ActionListener().
5) Is there a "javadoc" like thing for methods in C#?
I see stuff like:
/// <summary>
/// text...
/// </summary>
/// <param name...
I am guessing that is the C# javadoc equivalent. If so, how are the docs
generated, and does it create an HTML output?
6) VS.NET 2003 question
Is there a way to point at a class or variable and ask the IDE all the
places that it's being used in? For example, if I have class A, then give me
all the places class A is being used (for example of all the class A
instantions or all the places static methods of class A are being used).
Same with variables, if I have an instance variable in class A, show me
everywhere this var is being used.
7) Does 1.1 provide generics? Even if it does not, can you please provide a
simple example?
The java equivalent would be:
List<StringlistString = new ArrayList<String>();
listString.add("my string...");
listString.add("2nd string...");
// to iterate
for(String s : listString) {
System.out.println(s);
}
I'd like to see some of the generic creation syntax of C#.
8) Is version .NET 2 backwards compatible with 1.1? Can I use VS C# Express
2005 on a VS.NET 2003 project? Can I specify in 2005 Express that I want to
compile for .NET 1.1?
Thanks in advance.