TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
346k
Another problem with methods
Jan 15 2012 7:09 PM
Create a console-based application named Area. Include
three overloaded methods that compute the area of a
rectangle when two dimensions are passed to it. One
method takes two integers as parameters, one takes two
doubles, and the third takes an integer and a double.
Write a Main() method that demonstrates each method
works correctly.
I have done this
Console.WriteLine("Enter the hight of the rectangle:");
double stNumber = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the hight of the rectangle:");
double ndNumber = Convert.ToDouble(Console.ReadLine());
AreaOfRectangle(ref stNumber, ref ndNumber);
}
static void AreaOfRectangle(ref int length,ref int width)
{
int area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
static void AreaOfRectangle(ref double length,ref double width)
{
double area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
static void AreaOfRectangle(ref int length,ref double width)
{
double area;
area = length * width;
Console.WriteLine("The area of rectangle is {0}", area);
}
You think there's better way to do it?
Reply
Answers (
1
)
Problem with metohds
Method overload