Do we need to define the return type of the constructor.Or does it carry a
default return type
Why do program gives error if we use void with the constructor name
using System;
namespace ConsoleApplication18
{
public class Program
{
public int length, width;
public Program(int l, int w)
{
length= l;
width= w;
int area= l*w;
Console.WriteLine(area);
}
//return (area);
//Console.WriteLine("The length and width of the surface is {0} and
{0}", length, width);
//Console.WriteLine(area);
}
class Sample
{
static void Main()
{
Program p1 = new Program(10, 20);
{
Console.WriteLine(p1.length);
Console.WriteLine(p1.width);
//Console.WriteLine(p1.area);
Console.ReadKey();
}
}
}
}
In this program if I remove comments from
//Console.WriteLine("The length and width of the surface is {0} and
{0}", length, width);
//Console.WriteLine(area);
These two statements then what is wrong there
It gives error on removing comments.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---