Thursday, 17 May 2018

struct in C#



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication19

{

    class Program

    {

        static void Main(string[] args)

        {



            Rectangle r = new Rectangle(4,3);

            r.displayarea();

            Console.ReadLine();

        }

    }



    public struct Rectangle

    {

        int w, h;

        public Rectangle(int h, int w)

        {

            this.h = h;

            this.w = w;

        }



        public void displayarea()

        {



            Console.WriteLine("Area of Rectangle is "+(w*h));

        }



    }

}


No comments:

Post a Comment

Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...