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

Method Overirding and Overloading

using System.IO;
using System;

namespace consoleapplication
{
    public class A
    {
        public virtual void Display()
        {
            Console.WriteLine("ParentClass A");
        }
    }
    public class B:A
       {
           public override void Display()
           {
               Console.WriteLine("ChildClass B");
           }
       }
       class program
       {
           static void Main()
           {
               B obj = new B();
               obj.Display();
               Console.ReadLine();
           }
       }
}



public class Methodoveloading    
  {    
    public int add(int a, int b)  //two int type Parameters method  
    {    
        return a + b;    
        
    }    
    public int add(int a, int b,int c)  //three int type Parameters with same method same as above  
    {    
        return a + b+c;    
    
    }    
    public float add(float a, float b,float c,float d)  //four float type Parameters with same method same as above two method 
    {    
        return a + b+c+d;    
    
    }    
  }    

C# - Defining Constants

using System;

namespace DeclaringConstants {

    class Program {
    
        static void Main(string[] args) {
            const double pi = 3.14159;   
            
            // constant declaration 
            double r=6;
            Console.WriteLine("Enter Radius: ");
           r = Convert.ToDouble(Console.ReadLine());
            double areaCircle = pi * r * r;
            Console.WriteLine("Radius: {0}, Area: {1}", r, areaCircle);
            Console.ReadLine();
        }
    }
}

C# Type Conversion Methods

using System;

namespace TypeConversionApplication {
   
   class StringConversion {
      
      static void Main(string[] args) {
         int i = Convert.toDouble();;
         float f =24.33 ;
         double d = 2345.7652;
         bool b = true;
        
         Console.WriteLine(i);
         Console.WriteLine(f.ToString());
         Console.WriteLine(d.ToString());
         Console.WriteLine(b.ToString());
         Console.ReadKey();
            
      }
   }
}

Compile and Execute C# Sharp Online

using System.IO;
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello Priyanka");
        Console.WriteLine("Welcome to C Sharp Programming");
    }
}

Compile and Execute C# Sharp Online

using System;

namespace HelloWorldApplication {
   
   class HelloWorld {
      
      static void Main(string[] args) {
         /* my first program in C# */
         Console.WriteLine("Hello World");
         Console.ReadKey();
      }
   }
}
/* Binary Stuffs*/
uint32_t BCDadd(uint32_t a,uint32_t b)
{
    uint32_t  t1, t2;    // unsigned 32-bit intermediate values

    t1 = a + 0x06666666;
    t2 = t1 ^ b;                   // sum without carry propagation
    t1 = t1 + b;                   // provisional sum
    t2 = t1 ^ t2;                  // all the binary carry bits
    t2 = ~t2 & 0x11111110;         // just the BCD carry bits
    t2 = (t2 >> 2) | (t2 >> 3);    // correction
    return t1 - t2;                // corrected BCD sum
    /*text*/
    using System;

namespace That {
   
   class Hate {
      
      static void Main(string[] args) {
         /* my first program in C# */
         Console.WriteLine("I Hate You");
         Console.ReadKey();
      }
   }
}

C# Type Conversion Methods

using System;

namespace TypeConversionApplication {
   
   class StringConversion {
      
      static void Main(string[] args) {
         Console.WriteLine("enter number:");
        int num=Convert.ToInt32(Console.ReadLine());
       
      }
   }
}

C# - Enums

using System;

namespace Arrays_Indexers_Collections {

   class EnumProgram {
      enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };

      static void Main(string[] args) {
         int WeekdayStart = (int)Days.Mon;
         int WeekdayEnd = (int)Days.Fri;
         Console.WriteLine("Monday: {0}", WeekdayStart);
         Console.WriteLine("Friday: {0}", WeekdayEnd);
         Console.ReadKey();
      }
   }
}

myproj

using System.IO;
using System;

class Program
{
    static void Main()
    {
        Console.WriteLine("Hello, World!");
        Console.WriteLine("\n\n\t\t\tMy world My rules");
    }

Compile and Execute C# Sharp Online

using System;  
public class ArrayExample  
{  
    static void maxArray(int[] arr)  
    {  
        int min = arr[0];
           for (int i = 1; i < arr.Length; i++) {
            
           if(min > arr[i]){
               min = arr[i];
               Console.WriteLine("Minimum element is: " + min);  
           }
       }
    }  
    public static void Main(string[] args)  
    {  
        int[] arr1 = { 25, 10, 20, 15, 40, 50 };  
        int[] arr2 = { 12, 23, 44, 11, 54 };  
        int[] arr3 = {1,2,3,4,5,6,7};
        minArray(arr1);
        minArray(arr2);
        minArray(arr3);
    }  
}

Compile and Execute C# Sharp Online

using System.IO;
using System;
using static System.Console;

namespace MicrosoftEs2
{
        public BankAccount(string name, decimal initialBalance)
        {
                this.Owner = name;
                this.Balance = initialBalance
                this.Number = accountNumberSeed.ToString();
                accountNumberSeed++;
        }
        
    public class BankAccount
    {
            public string Number{get;}
            public string Owner{get; set;}
            public decimal Balance{get;}
            
            public void MakeDeposit(decimal amount, DateTime date, string note)
            {
                    
            }
            
            public void MakeWithdrawal(decimal amount, DateTime date, string note)
            {
                    
            }
            
            private static int accountNumberSeed = 1234567890;
    }
    
    class Program
    {
            static void Main(string[] args)
            {
                var account = new BankAccount("<name>", 1000);
                Console.WriteLine($"Account {account.Number} was created for {account.Owner} with {account.Balance} initial balance.");
            }
    }
}

Advertisements
Loading...

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