Results 1 to 25 of 28
Thread: C#
Hybrid View
-
25th November 2014 15:42 #1
C#
, ,
#:
class Program
{
static void RectangleArea()
{
Console.WriteLine("Let's calculate the area of a rectangle!");
Console.WriteLine("Please enter side 1: ");
float a = float.Parse(Console.ReadLine());
Console.WriteLine("Please enter side 2: ");
float b = float.Parse(Console.ReadLine());
}
static void RectangleAreaCalculate(float a, float b)
{
float area = a * b;
Console.WriteLine("The area is: " + area);
}
public static void Main(string[] args)
{
RectangleArea();
RectangleAreaCalculate();
}
}
RectangleAreaCalculate(); :
Error 1 No overload for method 'RectangleAreaCalculate' takes 0 arguments
b:
RectangleAreaCalculate(a, b);
:
Error 1 The name 'a' does not exist in the current context
Error 2 The name 'b' does not exist in the current context
? ? , Main?
-
25th November 2014 16:03 #2
a b RectangleArea() , main() RectangleAreaCalculate().
-
25th November 2014 16:10 #3
-
25th November 2014 16:18 #4
a b, RectangleArea(), .
.
- :
-:Code:class Program { public static float a, b; static void RectangleArea() { Console.WriteLine("Let's calculate the area of a rectangle!"); Console.WriteLine("Please enter side 1: "); a = float.Parse(Console.ReadLine()); Console.WriteLine("Please enter side 2: "); b = float.Parse(Console.ReadLine()); } static void RectangleAreaCalculate() { float area = a * b; Console.WriteLine("The area is: " + area); } public static void Main(string[] args) { RectangleArea(); RectangleAreaCalculate(); } }
:Code:class Program { public float a, b; void RectangleArea() { Console.WriteLine("Let's calculate the area of a rectangle!"); Console.WriteLine("Please enter side 1: "); a = float.Parse(Console.ReadLine()); Console.WriteLine("Please enter side 2: "); b = float.Parse(Console.ReadLine()); } void RectangleAreaCalculate() { float area = a * b; Console.WriteLine("The area is: " + area); } public static void Main(string[] args) { Program test = new Program(); test.RectangleArea(); test.RectangleAreaCalculate(); } }
Code:class Program { static float SetHeight() { Console.WriteLine("Please enter side 1: "); float a = float.Parse(Console.ReadLine()); return a; } static float SetLength() { Console.WriteLine("Please enter side 2: "); float b = float.Parse(Console.ReadLine()); return b; } static void RectangleAreaCalculate(float a, float b) { float area = a * b; Console.WriteLine("The area is: " + area); } public static void Main(string[] args) { Console.WriteLine("Let's calculate the area of a rectangle!"); RectangleAreaCalculate(SetHeight(), SetLength()); } }Last edited by axi; 25th November 2014 at 17:41.
-
26th November 2014 12:39 #5
, . C# - The Yellow Book C# by Rob Miles. , - C#. ( ) 600-700 , .
.. , 1-2 "" .MSI Z590 Gaming Plus|11600K|TRUE Spirit 140|32GB Patriot Viper 3600 C16|Asus RX 6800 TUF|980 Pro 1TB|EVGA 650G2|512+512gb Crucial|Arc Midi|GB3461WQSU|G502|CM Quickfire TK Brown|S.M.S.L M3|AKG K702
Overclock yourself, you must!!!
-
26th November 2014 14:32 #6
! . , , , . Stuen4y - . # ? , .
, !
-
26th November 2014 14:49 #7
, . - - .
MSI Z590 Gaming Plus|11600K|TRUE Spirit 140|32GB Patriot Viper 3600 C16|Asus RX 6800 TUF|980 Pro 1TB|EVGA 650G2|512+512gb Crucial|Arc Midi|GB3461WQSU|G502|CM Quickfire TK Brown|S.M.S.L M3|AKG K702
Overclock yourself, you must!!!
-
26th June 2015 07:53 #8
-
26th June 2015 08:33 #9
7 - if/else ...
Last edited by axi; 26th June 2015 at 08:35.
-
26th June 2015 09:56 #10
-
26th June 2015 09:58 #11
@Leader, - , -. . C#, ( , ): . , - !
-
26th June 2015 10:18 #12
-
26th June 2015 12:57 #13
Join Date: Apr:2006
Location:
Posts: 8,666
-
26th June 2015 13:28 #14
Camel/Pascal case Microsoft ( C# ): MSDN. .
: , , , ? "--, , " ?Last edited by Shmirgela; 26th June 2015 at 13:31.




Reply With Quote



Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in