Results 1 to 25 of 28

Thread: C#

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Michel Vaillant's Rival Leader's Avatar
    Join Date: Jan:2004
    Location:
    Posts: 2,646

    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?

  2. #2
    Registered User axi's Avatar
    Join Date: Aug:2013
    Location: Sofia
    Posts: 3,638
    a b RectangleArea() , main() RectangleAreaCalculate().

  3. #3
    Michel Vaillant's Rival Leader's Avatar
    Join Date: Jan:2004
    Location:
    Posts: 2,646
    , . ? .. ?

  4. #4
    Registered User axi's Avatar
    Join Date: Aug:2013
    Location: Sofia
    Posts: 3,638
    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.

  5. #5
    Quick Learner Stuen4y's Avatar
    Join Date: Oct:2006
    Location: Edinburgh
    Posts: 12,999
    Quote Originally Posted by Leader View Post
    , . ? .. ?
    , . 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!!!

  6. #6
    Michel Vaillant's Rival Leader's Avatar
    Join Date: Jan:2004
    Location:
    Posts: 2,646
    ! . , , , . Stuen4y - . # ? , . , !

  7. #7
    Quick Learner Stuen4y's Avatar
    Join Date: Oct:2006
    Location: Edinburgh
    Posts: 12,999
    , . - - .
    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!!!

  8. #8
    Registered User Shmirgela's Avatar
    Join Date: Aug:2002
    Location: .
    Posts: 1,940
    Quote Originally Posted by smelkomar View Post
    -? ...

    Code:
    //- 
    string[] myarray = {"!", "!", "!", "!", "!", "!", "!", "!", "!", "!"};
    if ((A >= 0) && (A < myarray.Length)) { Console.WriteLine(myarray[A]); } else { Console.WriteLine("Fuck off"); }

    if-else switch-case - ? ��✌️
    .. ��


    Sent from my iPad using Tapatalk
    Last edited by Shmirgela; 26th June 2015 at 09:52.

  9. #9
    Registered User axi's Avatar
    Join Date: Aug:2013
    Location: Sofia
    Posts: 3,638
    7 - if/else ...
    Last edited by axi; 26th June 2015 at 08:35.

  10. #10
    Michel Vaillant's Rival Leader's Avatar
    Join Date: Jan:2004
    Location:
    Posts: 2,646
    !

    , if/else , , , , , - -... .

  11. #11
    Registered User Shmirgela's Avatar
    Join Date: Aug:2002
    Location: .
    Posts: 1,940
    @Leader, - , -. . C#, ( , ): . , - !

  12. #12
    Michel Vaillant's Rival Leader's Avatar
    Join Date: Jan:2004
    Location:
    Posts: 2,646
    , !

  13. #13

    Join Date: Apr:2006
    Location:
    Posts: 8,666
    Quote Originally Posted by Shmirgela View Post
    ... , - !
    , - pascal case, camel case wHATEveR casE, 2

  14. #14
    Registered User Shmirgela's Avatar
    Join Date: Aug:2002
    Location: .
    Posts: 1,940
    Camel/Pascal case Microsoft ( C# ): MSDN. .
    : , , , ? "--, , " ?
    Last edited by Shmirgela; 26th June 2015 at 13:31.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |