local global in c#

 # local global variable in function.

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace LocalGlobal

{

    class Program

    {

        int a1;   // global variable

        // input function

        void input(int a )// int a is a local variable

 

        {

            a1 = a; // passing local to  global

        }

        // display  function

        void display()

        {

            Console.WriteLine(a1);

 

        }

        static void Main(string[] args)

        {

            Program p1 = new Program();

            p1.input(31);

            p1.display();

            Console.ReadKey();

 

        }

    }

}

Task 1 convert local global concept into c# any 1.

 

# Oops object oriented programming.

What is class ?

A class is a collection of member and method.

Member – it is a variable inside the class.

Method- Function inside the class.

 

# Types of classes

1. System class- auto generated

2. User class- created by user

 

# Oops approach

1. Bottom to up approach

# programming language-top to bottom

 

C++ is a partially object oriented program (support oops)

· In c# all user classes is to be created before main class(system class)

· Syntax-

· Class name

                   {   

                     member

                         method

                     }

· By default class is a private property.

 

# class accessibility:-

1. Internal class method- programming

2. External class method – development

 

# we don’t have to count system class while counting the user define class .

Ex for internal class

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

namespace @class

{

    class student

    {

        public

        void display()

        {

            Console.WriteLine("Welcome");

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            student s1 = new student();

            s1.display();

            Console.ReadKey();

        }

    }

}

Comments

Popular posts from this blog

ViewState for state management

Store procedure Data Base handling (procedure_insert).

Database joining