| | |
Body-less method declaration
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2009
Posts: 3
Reputation:
Solved Threads: 0
Hello
I have seen the following method syntax and I am trying to understand how this works/or doesn't:
public class MyClass
{
public MyClass();
public MyClass(string param);
}
There is no implementation of the methods (constructors) and class is not declared virtual either...
Is this something new in C# 3.0 ???
Any ideas???
Thank you
I have seen the following method syntax and I am trying to understand how this works/or doesn't:
public class MyClass
{
public MyClass();
public MyClass(string param);
}
There is no implementation of the methods (constructors) and class is not declared virtual either...
Is this something new in C# 3.0 ???
Any ideas???
Thank you
0
#2 33 Days Ago
That doesn't compile in 3.5 and I think the error message answers your question:
Interfaces allow you to declare methods similarly but the method must have a return type:
I suspect you were looking at partial class definitions.
text Syntax (Toggle Plain Text)
'daniweb.MyClass.MyClass()' must declare a body because it is not marked abstract, extern, or partial 'daniweb.MyClass.MyClass(string)' must declare a body because it is not marked abstract, extern, or partial
Interfaces allow you to declare methods similarly but the method must have a return type:
C# Syntax (Toggle Plain Text)
public interface ITest { void ITest(); }
I suspect you were looking at partial class definitions.
0
#4 33 Days Ago
You can't have abstract constructors since the child classes cannot implement constructors from an inherited class...
None of these are valid:
None of these are valid:
C# Syntax (Toggle Plain Text)
public abstract class AbstractClass { abstract AbstractClass(); } public abstract class AbstractClass2 { AbstractClass2(); } public class AbstractClass3 { abstract AbstractClass3(); }
•
•
Join Date: Jul 2009
Posts: 886
Reputation:
Solved Threads: 140
•
•
•
•
Hello
I have seen the following method syntax and I am trying to understand how this works/or doesn't:
public class MyClass
{
public MyClass();
public MyClass(string param);
}
There is no implementation of the methods (constructors) and class is not declared virtual either...
Is this something new in C# 3.0 ???
Any ideas???
Thank you
Last edited by DdoubleD; 32 Days Ago at 9:33 am.
![]() |
Similar Threads
- missing return statement (Java)
- abstract and interfaces (C#)
- virtual void method() = 0; problem (C++)
- setAttribute and IE7 (JavaScript / DHTML / AJAX)
- how is abstact class different from Interface?? (Java)
- Seven Parallel Vectors (Java)
- Problems with overload operator method (C++)
- Method problems (Java)
- Fibonacci Recursion - Illegal Start of expression! (Java)
- Combined data type arrays. (C++)
Other Threads in the C# Forum
- Previous Thread: Mouse Pointer moves on specified location dynamically
- Next Thread: DataReader clean up
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem httpwebrequest image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






