Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

C# Basic Syntax

using System;
using RectangleApplication;

namespace MyNamespace {
    
   class MyTest {
       static void Main(string[] args){
           Console.WriteLine("It works!!");
           
           Rectangle r = new Rectangle();
           r.Acceptdetails();
           r.Display();
       }
   }
    
}

namespace RectangleApplication {
   
   class Rectangle {
      // member variables
      double length;
      double width;
      
      public void Acceptdetails() {
         length = 4.5;    
         width = 3.5;
      }
      
      public double GetArea() {
         return length * width; 
      }
      
      public void Display() {
         Console.WriteLine("Length: {0}", length);
         Console.WriteLine("Width: {0}", width);
         Console.WriteLine("Area: {0}", GetArea());
      }
   }
   
   class ExecuteRectangle {
   
    //   static void Main(string[] args) {
    //      Rectangle r = new Rectangle();
    //      r.Acceptdetails();
    //      r.Display();
    //      Console.ReadLine(); 
    //   }
   }
}











Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.