We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Monday, May 25, 2020

Inheritance examples in C#

using System;

namespace ProgramDemo
{
    class A
    {
        public int Add()
        {
            return 8 + 9;
        }
    }
    class B:A
    {
        public int Add()//Warning
        {
            return 5 + 5;
        }
        public int Add1()//Warning
        {
            return 9 + 5;
        }
    }
    class C:B
    {
        public  int Add()//Warning or you have to give new keword
        {
            return 4 + 4;
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            A a = new A();
            A ab = new B();
            A ac = new C();
            // B ba=new A()->Error
            B b = new B();
            B bc = new C();
            C c = new C();

            Console.WriteLine(a.Add());
            Console.WriteLine(ab.Add());
            Console.WriteLine(ac.Add());
            Console.WriteLine(b.Add());
            Console.WriteLine(b.Add1());
            Console.WriteLine(bc.Add());
            Console.WriteLine(c.Add());
            Console.ReadLine();
        }
    }
}


Sunday, March 15, 2020

How Find the Smallest Word in give string array in C#

Problem Description

Given a string of characters, find the smallest word if two or more words are the smallest then display the one that occurs first in the string.

Example:

String a ={ "a", "bb", "dddd", "cccc", "ffffff", "eeeee" };
Output = 
a;


class Example
    {

       public static void Main()
        {
            string[] str = new string[6] { "a""bb""dddd""cccc""ffffff""eeeeee" };

            string temp = "";
            int a = 0;
            for (int i = 0; i < str.Length; i++)
            {
              
                if (a==0)
                {
                    temp = str[i];
                }
                else
                {
                    if (a > str[i].Length)
                    {
                        temp = str[i];
                    }
                  
                }
                a = temp.Length;
            }
            Console.WriteLine(temp);
            Console.ReadLine();
        }
    }

Output:

How Find the Largest Word in give string array in C#

Problem Description

Given a string of characters, find the largest word if two or more words are the largest then display the one that occurs first in the string.

Example:

String a ={ "a", "bb", "dddd", "cccc", "ffffff", "eeeee" };
Output = 
ffffff;

class Example
    {

       public static void Main()
        {
            string[] str = new string[6] { "a", "bb", "dddd", "cccc", "ffffff", "eeeeee" };

            string temp = "";
            int a = 0;
            for (int i = 0; i < str.Length; i++)
            {
              
                if (a==0)
                {
                    temp = str[i];
                }
                else
                {
                    if (a < str[i].Length)
                    {
                        temp = str[i];
                    }
                  
                }
                a = temp.Length;
            }
            Console.WriteLine(temp);
            Console.ReadLine();
        }
    }

Output