i
Quote:
Original post by Darklighter
Thanks for the clarification, Telastyn. For further reference concerning my other question, it is also possible for Main() to return an int in C#, according to MSDN. I have a few more questions regarding Chapter I before moving on though. I have a background in C++, so some of my questions might relate to C++ concepts.
I will see how many of these I can help you with.
Quote:
- Considering the following code snippet from the specification:
public class Point3D: Point{ public int z; public Point3D(int x, int y, int z): Point(x, y) { this.z = z; }}
How come the compiler complains when calling the base constructor as so? It expects base() or this() instead. Am I missing something?
The correct C# way of doing this;
[source lang=c#]public class Point3D: Point{ public int z; public Point3D(int x, int y, int z):base(x, y) { this.z = z; }
Quote:
Out of curiosity, are the Windows Forms properties actual C# properties?
Yes they are actually properties.
Quote:
C# Specification, p.25
...it is not possible to create references to structs, which rules out their usage in a number of situations.
What are some examples of such situations?
The biggest ones that I can think of is when you have a struct that is large or when you have to pass it around a lot and it is medium size. [opinion]Any time I have a struct that gets pretty large I convert it over to a class, so it will be used by reference instead of by value.[/opinion]
Quote:
Are default parameters permitted in C#?
No it does not, well not directly. That is what overloading is for.
[source lang=c#]public int foo(int a, float b, string c){ /// Do something with a, b, c}public int foo(int a, float b){ string c = "Some string"; /// Do something with a, b, c}public int foo(int a){ string c = "Some string"; float b = 1.8f; /// Do something with a, b, c}public int foo(){ string c = "Some string"; float b = 1.8f; int a = 7; /// Do something with a, b, c}
That gives you the same abilities of default parameters.
Quote:
Is it possible to separate a method's implementation from its declaration (i.e. not cluttering the class' declaration with function bodies)?
Not really, there are partial classes, but that doesn't really do what you are wanting to do.
Quote:
How can one declare a method to be const (i.e. unable to modify this)?
Not sure what you are looking for, can you explain?
Quote:
If I understood correctly, it's impossible to provide an implementation to an abstract method for overridden ones to chain up, right? Also, are explicit calls to base methods that have been overridden allowed?
Right, abstract methods have no implementation in the base class. As for the second part, it depends. Going to suggest you read this; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/csspec/html/vclrfcsharpspec_10_5_4.asp
Quote:
Considering the following code snippet:
int i = new int();
Is i placed on the stack or allocated dynamically? I'm guessing it's the former. If so, is it possible to declare a reference to an int other than using ref?
From what I understand, the stact. And no, ref and out are the only way to referece a value type.
Hope that helps.
theTroll