Tuesday 15 May 2018

Static Class and Method in C#



Mathematics Class: 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace ConsoleApplication16.Model

{

   static class Mathematics

    {

       public static float pi = 3.124f;

   public static double areaofcircle(float r)

   {

       return pi * Math.Pow(r, 2);

       



   }





   public static double circumferencecircle(float r)

   {

       return 2 * pi * r;





   }







   }



}

Main class:
using ConsoleApplication16.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication16
{
    class Program
    {
        static void Main(string[] args)
        {

            float r;
            l1:
            Console.WriteLine("Enter the radius of circle:");
            r = float.Parse(Console.ReadLine());
            if (r<0)
            {
                Console.ForegroundColor = System.ConsoleColor.Red;
                Console.WriteLine("Radius cannot be negative.....");
             Console.ForegroundColor=System.ConsoleColor.White;
            }
            else
            {
                Console.ForegroundColor = System.ConsoleColor.Green;
                Console.WriteLine("Area of Circle is " + Mathematics.areaofcircle(r));
                Console.ForegroundColor = System.ConsoleColor.Magenta;
                Console.WriteLine("Circumference  of Circle is " + Mathematics.circumferencecircle(r));
                Console.ForegroundColor = System.ConsoleColor.White;
            }
            Console.WriteLine("Press any key to continue....");
            Console.ReadKey();
            Console.Clear();
            goto l1;
        }
    }
}


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 ...