We can use the dot notation to call the area() method to compute the area of the new rectangle. ObjectReference must be a reference to an object. Syntax for calling a method through object: If the method does not require any arguments, use empty parentheses. Also, we provide any arguments to the method within enclosing parentheses. We append the method name to an object reference with an intervening period (.). This Java statement calls rect’s setval method with two integer parameters 20 and 10 and that method assigns new values to variables l and b respectively. To set the values of the variables l and b, we use this method: Here, in this article, I try to explain how to Calculate the Perimeter of the Rectangle in C# with Examples and I hope you enjoy this ("Area of Rectangle is : "+rect.area()) VisualStudio programmingLet's calculate the area and the perimeter of a rectangle in C in visual studioThis video also shows the use of the function of sc. In the next article, I am going to discuss Calculate Perimeter of Square in C# with Examples. Or the same above 2 lines of code can be replaced with PerimeterOfRectangle obj = new PerimeterOfRectangle() Ĭonsole.Write("Perimeter of rectangle is: " + obj.CalculatePerimeterOfRectangel(length, width)) ĭecimal CalculatePerimeterOfRectangel(decimal length, decimal width)ĭecimal perimeter = 2 * (length + width) using System ĭecimal length = Convert.ToDecimal(Console.ReadLine()) ĭecimal width = Convert.ToDecimal(Console.ReadLine()) In the below C# example, we have created one method to calculate the perimeter of the Rectangle. using System Ĭonsole.Write("Enter the value of length : ") ĭecimal Length = Convert.ToDecimal(Console.ReadLine()) Ĭonsole.Write("Enter the value of width : ") ĭecimal Width = Convert.ToDecimal(Console.ReadLine()) ĭecimal Perimeter = 2 * (Length + Width) Ĭonsole.Write("Perimeter of Rectangle is: " + Perimeter) The following C# Program will calculate the Perimeter of the Rectangle. android open-source calculator area-calculator android-open-source calculator-application bmi-calculator discount-calculation android-opensource percentage-calculator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |