.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Interview Question >> C# >> Post New Question Subscribe to Interview Questions

Why do I get an error (CS1006) when trying to declare a method without specifying a return type?

Posted By :nishithraj     Posted Date :November 30, 2009    Points :10   Category :C# 
If you leave off the return type on a method declaration, the compiler thinks you are trying to declare a constructor. So if you are trying to declare a method that returns nothing, use void. The following is an example: // This results in a CS1006 error public static staticMethod (mainStatic obj) // This will work as wanted public static void staticMethod (mainStatic obj)

You can also find related Interview Question to Why do I get an error (CS1006) when trying to declare a method without specifying a return type?  below: 

What is return type of Executenonquery() ?

  
int will be returned when you call ExecuteNonQuery() in ADO.NET (More...)

How do I call a member method and pass a primitive type (Value Type) by reference?

  
Use the ref keyword when declaring the parameter of the method, for example:

public bool GetValue( ref int returnValue );

This will pass the numeric by reference.You can modify the value of returnValue within the body of GetValue and it will persist when the method call returns. (More...)

Can you declare an override method to be static if the original method is not static?

  
No. The signature of the virtual method must remain the same.
(Note: Only the keyword virtual is changed to keyword override). (More...)

Which method is used to return an item from the Top of the Stack?

  
Pop()method is used to return an item from the Top of the Stack (More...)

Can you declare the override method static while the original method is non-static?

  
No, you can't, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override. (More...)

Can we declare variables with xml data type?

  
Yes, variables can be declared of xml data type that can hold xml data (More...)

Can we declare column with xml data type to hold xml data?

  
Yes, A column with xml data type can be declared. (More...)

How do you declare a Numeric type to String?

  
Call System.Object.Tostring()
For Example
int idx =0;
string str - idx.ToString();
(More...)

How do you call a Member method and pass a value Type by reference?

  
use the "ref" keyword when declaring a Parameter of the Method
Ex:
public bool GetValue(ref int returnvalue);
(More...)

Do event have return type?

  
No, event does not have return type? (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

 
Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.


Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend