C# Programming

 Dotnet Framework

Topics :

01. Dotnet Environment
02. Console Application
03. What is programming
04. Compiler
05. Interpreter
06. types of compiler
07. C# statement
08. C# function
09. How to create function
10. How to access function
11. Function parameter
12. User input
13. How to create multiple parameter
14. Named parameter
15. Unnamed parameter
16. Local and global variable in function
17. Function Methodology
18. Container variable
19. How to return multiple value in function
20. How to create tuple
21. How to return multiple value using tuple
22. Default Argument
23. C# Mathematical Functions
24. C# Arrays
25. Types of Allocation
26. Array Property
27. Array Separator
28. Error Representation
29. How to Create Array in C#
30. How to Store data element in Array
31. Types of loop in Array
32. Array Initialization
33. Array Methods
34. Array Sorting Using sort()
35. For Each
36. Double Dimensional Array
37. C# Structure
38. How to access structure members
39. Types of Code
40. params Parameter
41. How to Create Params parameter
42. How to pass user input array to function
43. String Handling Function in C#
44. Namespace
45. How to Create namespace
46. C# Exception Handling
47. Try Catch
48. Finally
49. Throw - imp
50. String Builder - most imp
51. Method of String Builder




  •  Programming is a set of code
  •  Framework is a collection of tools, library, resources.
  •  Dot net support language (imp)
           1. Visual basic
           2. C#

1. Dotnet environment(imp)

1. window environment
2. web environment – asp dotnet
3. console environment – support programming fundamentals

2. Console Application

File > new > visual# > consoleApplication > Highest version
File > new > project > seach (consolef(dotnetframework)C#) > next > location Select folder > create



using System;      (representing library)
namespace ConsoleApp1;      (representing program body)
public class HelloWorld      (class representing object oriented approach)
{
public static void Main(string[] args)
{
Console.WriteLine ("Hello Mono World");
}
}


  • C++ is a partial object oriented language (not compulsory)
  • Pure object oriented Java, C# etc.
  • Main function directly execute by compiler in c#

3. What is programming
    Programming is a series of valid instruction

4. Compiler (imp)

- Properties :
1. compiler is use to grouping method
2. compiler is representing syntax error (semicolon missing etc.)

5. Interpreter

1. it is use to step by step instruction
2. it returning logical error



6. Types of Compiler

1. On Compiler
    Cannot use event handling
    All time activate in a program

2. Off Compiler
    Work only for event (JIT compiler)



7. C# Statements

1. Output statement
2. Input Statement

Numerical input – int.parse()
Decimal input – double.parse()
String input – direct reading
Console.ReadLine() – for input purpose

All purple color representing function



Assignment 1
Convert all conditional statement program into c#

Assignment 2
Input following information from the user
Name
City
State
Mobile
College
Subject
Mark1
Mark2
Mark3
Mark4
Mark5
Total
Grade
Logic
    1. Calculate total if all subject mark greater than 40
    2. Check the following conditions
        Total>250 – Agrade
        Total > 150 & total < 250 B grade
        Total > 100 and <150 Cgrade



Assignment 3
Convert all loop assignment into C#
All assignments send using word file




8. Csharp Function :

-Function is a small job program
-Function seperater ()
-function definition (create a function)
-function calling (Access function)
-variable property(return value is called function property)
-function statement (container)




9. How to create function in C#
    - all function in c# create a before main body Location

Syntax:
    Type functionname()
    {
        statement;
    }

    -void is a default type any function(no return value)

Ex.
    Void display()
    {

    }

    Void show()
    {

    }

10. How to access function in a C#

- all function is to be access with the help of object
- all object is to be created inside the main body

Syntax:
        Classname objname = new classname();

- new is memory allocation operator
- object is a communication between class body to main body
- function approach (bottom_up approch)



11. Function parameter (argument)

1. Receiver (Formal Argument)
    - At the time of function creation

2. Sender (Actual Argument)
    At the time of function calling






12. User input

        1. All types of input fundamentals inside main body






13. How to create multiple parameter






Que : write a program to generate following result

Create a function input
Accept following parameter (name,city,age,m1,m2,m3,m4,m5)
Logic
    1. Calculate total
    2. Check the following condition
    1. Total>250 && age > 25 then print A grade
    2. Total >150 && age > 18 && age < 25 && total <250 then print b grade
    3. Otherwise print try again
All parameter accept by the user


14. Named parameter(imp)

- In this concept pass all the parameters value with parameter name
- Resolve the argument mismatch error

Syntax :
    ParameterName : value






15. Un Named Parameter
        - Direct value pass


16. Local and Global variable in a function






Assignment 1

Create fun – input accept following parameters
Roll, name, city, state, clg, mob, branch,sub,percentage
Create a function display()
Accept all parameter inside display function(exclude per parameter)
Display all information inside display()
Create function grade() – accept only percentage parameter
Check the following condition
Per>60 – 1st division
Per > 50 %% per < 60 - 2nd division
Per > 40 && per <50 – 3rd division
Otherwise fail



Logic
1. Using named parameter concept
2. All parameter accept by the user
3. Inside the main body only access input function(function within function)



17. Function Methodology

1. No argument no return
Ex. 
        Void show()
        {

         }

        Show();


2. Argument but no return
Ex. 
        Void display(int a)
        {
            Console.writeline(a);
        }

        Display(10);


3. Argument or Return
    - By default function return single value at a time
    - All value is to be return using return keywork
    - Void keyword cannot use return statement




18. Container variable
    - It store return data value





19. How to return multiple value in a function (imp)

- Int this concept we had to us tuple library

- Tuple is use to returning multitype data value in a function


20. How to create tuple

Tuple<datatype1,datatype2,datatype3> nameoffunction(datatype1,datatype2,datatype3)
{

}

Ex.
    Public Tuple<int,string,double> input(int roll, string name, double price)
    {
        return;
    }



21. How to return multiple value using tuple

return new Tuple<datatype1,datatype2,datatype3>(parameter1,parameter2,parameter3);

Ex.
        Return new Tuple<int,string,double>(roll,name,price);

- All types of members in tuple called item
     Roll = item1
     Name = item2
     Price = item3

- Tuple is use to dynamic property
- All types of dynamic variable is to be create using var keyword





22. Default Argument






Assignment 2
Using default argument concept (Assignment1)
City = “nagpur”


Assignment 3
Convert all javaScript function assignment into C#


Assignment 4
Create you’re idea using tuple method


23. C# Mathematical Function :

        - All mathematical function stored inside math library



24. C# Array

    Int a ;
    - Variable is use to dynamic allocation property
        Arr = b(10,30,40,50)
    - Array is a linear type data structure and create sequential memory allocation
    - In c# array is use to memory allocation operator (new)


25. Types of allocation – imp

        Int a; -                       Design time Allocation (static )

        (use in Array) -         Run time allocation(dynamic)

        Variable property – Override

26. Array Property

    - Collection of similar type data elememt

Ex.
     a(10,20,30) is called array
     B(10,a,b) B not in Array

27.  Array Seperator – [] is called array separator


28. Error Representation

        1. Variable is returning undefined error
        2. is returning garbage error(memory not required)


29. How to create array in C#

    - In C programming
    Int a[5] – 5 is called subscript value

Syntax :
    Datatype [] arrayname = new datatype[subscriptvalue];

Ex :
    Int [] a = new int[5];


30. How to store data element in array

1. Using subscript method
2. Using iteration (looping)


31. Types of loop in Array
    There are two types of loop
        1.input loop
        2.output loop

- All types of logic implemented inside output loop
- How to find length of array - using length function




Assignment 1 Question
1. Sum of array element
3. Even number of arr element
4. Odd number of array element
5. Greater number of array element
6. small number of array element


Assignment 2
Generate the following result
Input subscript value from the user and store data element as per subscript value
Result :
Enter your subscript value – 7
Input 7 elements
10,30,40,50,60,70,80


32. Array Initialization
Syntax : 
    Datatype [] arrayname = {value}

Ex.
    Int [] a1 = {10,20,30};



33. Array Methods
    1. max method
    2. min method
    3. sum method
    4. sort method



34. Array Sorting using sort()
        Array.Sort(arrayname);

    - Sort method is use to foreach loop 


35. ForEach

- for each is use to object looping
- foreach cannot use lessthan greaterthan <=,>=

Syntax : 
    foreach(variable in object)
    {

    }

 

Assignment 3
Generate the following result
Create user define array and perform following operation in user choice
1. sum
2. min
3. max
4. sort



36. Double Dimensional array (row and column)


Syntax
        Datatype [,] arrayname = new datatype[r,c];

Ex
        Int [,] a = new int[3,3];

    1 2 3
    4 5 6
    7 8 9

Console.write(“/t”);
Console.write(“/n”)




Assignment 4
Find even
Find odd no

1 2 3
4 5 6
7 8 9
Sum sum sum

1 2 3 = sum
4 5 6 = sum
7 8 9 = sum


37. C# Structure

- Structure is a collection of defferent type data elements

Ex
    a(int,string,double)

- structure is to be create struct keyword

Syntax :
struct name
{
    member
};

Ex.
struct student
{
    Int roll;
    String name;
    Double percentage;
};

- Structure is to be create before the main class
- By default all structure member is private



38. How to access structure member


- Structure is to be access with the help of object(inside the main body)

Syntax
    Structurename objname;
Ex.
    Student s1;




39. Types of code - 
Imp :

- Unorganized code

Int roll , id, cardno, receiptno, admissionno, per,total;
String name , city, empname,empcity, clg, branch, semester, subject, division, designation,company,hr

- Organized Code

Struct student
{
    Roll,name,city,state,sem,per
};

Struct Employee
{
    Name, dsg,hr
};

- Create organized code in a program with the help of structure



Assignment 5
Create a class – College
Create a method – input()
Parameter name- roll, name,city,branch,percentage
Create a structure student
Create a member - roll, name,city,branch,percentage

Logic
1. input all parameters by the user structure member
2. pass all parameters (input method) using structure member
3. in parameter concept using named parameter
4. generate the following condition
per > 60 1st division
per > 50 && per < 60 – 2nd division
per > 40 && per < 50 – 3rd division
otherwise fail 


40. Params Parameter
    - Params is representing parameter in a form of array
    - Params is representing dynamic array
    - All types of data value store in param parameter (user input/initialization)

41. How to Create Params parameter

Syntax
    Params arrayvariable
    Int[] – this is a dynamic array

42. How to pass user input array to function

43. String Handling Function in C#

Note que : how to identify compiler a space symbol?
Ans : With ascii code 32


Assigment 2

Convert all string handling function to user input option based


44. NameSpace - imp


1. Array – Collection of similar type element
2. structure – collection of defferent data value
3. Namespace – collection of classes

    - namespace is use to create (namespace) keyword
    - namespace is use to organize class entity in proper manner



45. How to Create namespace

Syntax :

    Namespace name
    {
        Class Entity
    }

Ex.
    
    Namespace Student
    {
        Class Admission
        Class Result
        Class Degree
    }


Admission a1 = new Admission();

Student.Addmission a1 = new Student.Addmission();



A3

Create a namespace – Student
Create a class – Addmission
Create a method – input
Accept following parameter – name , city, age , per
Create a namespace College
Create a class – result
Create a method – grade
1.display all info inside grade()
And check following condition
Per>60 – Agrade
Otherwise b Grade



46. C# Exception Handling
    - Exception is representing all types of logical error in a program
    - Exception is a predefined class for containing all types of logical error

There are following method is use to exception handling

1.TryCatch
2.Finally
3.Throw


47. Try Catch
    - it is a exception handling method returning logical method

Syntax :
    Try
    {
            //logic
    }

    Catch(Exception obj)
    {
        //print error
    }









48. Finally
    - Finally statement is returning comments on computer screen
    - Finally is use to after try and catch block

    Try
    {
        //logic
    }
     Catch(Exception obj)
    {
        //printexception
    }
    Finally
    {
        //comment messege
    }




49. Throw - imp
    - Throw statement is basically use to jumping any types of exception as per condition
    - Throw statement is use to specific library called text




 50. String Builder - most imp


String name = “ramesh”;
String name = “suresh”;

String name1 = “rajkamal”;

- Deference between string and string builder
- String variable allocate multiple memory in a computer
- String builder allocate in a computer memory and mange multiple string at a time
- String builder is use specific library(text)
- String builder is use to index data value  


//create string builder class object

StringBuilder sb = new StringBuilder(50); //allocate 50 character space





51. Method of String Builder





Focus Point for Developement

1. Abstract, sealed class
2. Interface
3. Inheritance
4. Params parameter
5. Tuple
6. Function argument concept
7. Exception handling
8. Comment line
9. Dynamic variable concept
10. Throw statement



Comments

Popular posts from this blog

Web Application Development (Dot Net)

SQL(Structure Query Language)