Find the best tutors and institutes for C# .NET

Find Best C# .NET

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Outside India?

Search for topics

C# .NET Updates

Ask a Question

Post a Lesson

All

All

Lessons

Discussion

Lesson Posted on 28 Jun .Net/C# .NET

What are Various Types of Exception in C#

Suprio D.

Having training experience in dot-net Platform(3.5 LinQ,and wcf framework,webservices,MVC 4).. Applications),trained...

ArgumentException, ArgumentNullException, and ArgumentOutOfRangeException. NullReferenceException, IndexOutOfRangeException, SQL exceptions Stack Overflow Exception, Invalid Castexception ArgumentException occurs due to the appearance of invalid argument types argument null exception is due... read more

 

  • ArgumentException, ArgumentNullException, and ArgumentOutOfRangeException.
  • NullReferenceException, IndexOutOfRangeException, SQL exceptions
  • Stack Overflow Exception, Invalid Castexception

ArgumentException occurs due to the appearance of invalid argument types

argument null exception is due to null argument appearances. and out of range is when argument is defined which exceeds within its own bound levels.

null reference exception is when referencing an object you come across null character.

 IndexOutOfRangeException is when the index is defined beyond the actual bound levels. like in arrays. carrying integers of other characters.

sql exception is when mismatch happens between the number of rows or columns or irrelevant data types happens when client-side access the server side. in the database.

InvalidCastexception happens when the wrong type of casting happens between to data types for example between string and integer.

StackOverflowException happens when stacks try to acquire values beyond its own bound levels preassigned.

 

 

 

read less
Comments
Dislike Bookmark

Lesson Posted on 30 Mar .Net IT Courses/Programming Languages/C Sharp .Net/C# .NET

"foreach" loop in C#

Raga Deepthi Gade

I am an experienced .NET professional with over 8+ years of experience in teaching C , C# , Asp.Net ,...

foreach is a looping statement : repeats a group of statements for each element in an array or an object collection. (or) used to iterate through the collection/ an array to get the required information. Advantages: Easy implementation. Least possibility of errors. Syntax: foreach(<datatype... read more

foreach is a looping statement :

  • repeats a group of statements for each element in an array or an object collection. (or)
  • used to iterate through the collection/ an array to get the required information.

Advantages:

  • Easy implementation.
  • Least possibility of errors. [ especially when working with index based values, like in arrays. ]

Syntax:

foreach(<datatype of collection / array> <variablename> <in> <collection/array>)
{

code....

}

Example:

foreach(string courseName in coursesList)
{

code....

}

  • here, coursesList is a string collection
  • string courseName is called as the "loop variable" which represents the element from the collection in each iteration.
  • in is the pre-defined keyword

Working style of foreach loop:

  • data type of loop variable must and should be the same as the data type of the array/collection that has to be referred.
  • At the time of execution, first the foreach loop goes to the array/collection, counts the number of elements & repeats the loop that many times automatically.
  • At each iteration array/collection location value will be copied into loop variable.

Example 1: In the below example, we'll see how to iterate a group of int type array elements using foreach loop.

 

 

Example 2: In the below example, we'll see how to iterate a group of values in a collection.

NOTE : in .NET we've different types of collections. For example we took "List" a generic collection

 

 

read less
Comments 1
Dislike Bookmark

Lesson Posted on 03 Jan .Net/C# .NET

OOPs Concepts

Samir Bhogayta

Session Objectives: Discuss the following: Drawbacks of traditional programming Need for Object: Oriented approach Object: Oriented techniques Discuss Object: Oriented Concepts Objects. Classes. Abstraction. Inheritance. Encapsulation. Polymorphism. Need for OOP: Languages like C... read more

Session Objectives:

Discuss the following:

Drawbacks of traditional programming

Need for Object: Oriented approach

Object: Oriented techniques

Discuss Object: Oriented Concepts

  • Objects.
  • Classes.
  • Abstraction.
  • Inheritance.
  • Encapsulation.
  • Polymorphism.

Need for OOP:

  • Languages like C use the traditional programming approach for application development.
  • In this approach, we divide the application into several tasks and write code for all tasks.
  • Therefore, the focus in this approach is on the tasks and not on the objects.
  • The traditional programming approach was not able to handle the increasing demand of software applications

The drawbacks of Traditional Programming approach are:

  • Unmanageable Programs.
  • Code Reusability not Optimum.
  • Problems in Modification of Data.
  • Difficulty in Implementation.

Benefits of Object Oriented Programming approach are:

  • OOP offers better implementation.
  • OOP offers better data security.
  • OOP offers better code reusability.
  • OOP offers more flexibility.
  • OOP offers better manageable programs.

Objects:

  • An object represents an entity in the real world.
  • An object is simply something that is relevant to a particular application.
  • An object is a concept or a thing, with defined boundaries, that is relevant to the problem being dealt with.

Classes:

  • A class is a mould or a template of an object.
  • A class is what defines all the data members and the methods that an object should have.
  • The class defines the characteristics that the object will possess;it could also be referred to as a blueprint of the object.
  • Each object is said to be an instance of the class.
  • A class can contain any of the following as its members Properties / Fields,Methods,Constructors & Destructors
  • Properties: A characteristic required of an object when represented in a class is called a property or a field.
  • Method: A method is similar to a function, routine or a procedure; here it is associated to a class.
  • Constructor / Destructor: These are special types of methods that execute when an object is initialized or destroyed respectively.

Abstraction:

  • Data abstraction enhances security as use of data is restricted to certain functions only.
  • Abstraction is more used where you want only a certain number of functions/methods are accessing data

Inheritance:

  • We can incorporate the functionality of existing classes into any other class just by inheriting the new class from the existing class.
  • The existing class is called the BASE class and the newly created class is called the DERIVED class.

Data Encapsulation:

  • Grouping of data and methods into a single entity is known as Data Encapsulation

Polymorphism:

  • Object: Oriented languages try to make existing code easily modifiable without changing the code much.
  • Polymorphism allows functions to take more than one form.
  • Polymorphism enables the same method to behave differently on different classes.

 

read less
Comments
Dislike Bookmark

Looking for C# .NET

Find best C# .NET in your locality on UrbanPro.

FIND NOW

Lesson Posted on 12/10/2017 .Net/C# .NET

Object Initializers And Collection Initializers: A Syntactic Sugar In C# 3.0

Debendra Prasad Dash

4+ years of experiance in software industry.Nearly 1 year in software trainer.

i. Introduction: Object initializers and Collection initializers are part of C# 3.0.These two concepts add a flexibility, readability, and maintainability in C#. As we are C# developers, we should know how and in which situations we can use these two concepts and inprove our programming logic. Before... read more

i. Introduction:

Object initializers and Collection initializers are part of C# 3.0.These two concepts add a flexibility, readability, and maintainability in C#. As we are C# developers, we should know how and in which situations we can use these two concepts and inprove our programming logic. Before going deep, dive into object and collection initializers. We will check what are these Syntactic Sugars.

ii. Syntactic sugar in programming:

Syntactic sugar, or syntax sugar, is considered as a "shortcut" provided by the language, which reduces the amount of code that must be written in a particular situation.

Syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

The main benifits of using syntatic sugar in programming are:

  1. Avoid lot of keystrokes,The efficiency of software programs is sometimes measured by the number of keystrokes it requires to write a specific function.

  2. Easy to readable and maintainable.

  3. Time saving approach.

Let's see an example of  how we can use syntactic sugar in our program. Let's consider an example of normal IF-ELSE conditional statement:

class Program
{
static void Main(string[] args)
{
int x = 20, y = 10;
if (x>y)
{
Console.WriteLine(x);

}
else
{
Console.WriteLine(y);

}
Console.ReadLine();

}
Now, let's use Ternary operators and see how much key strokes we can prevent using Ternary operator.
class Program
{
static void Main(string[] args)
{
int x = 20, y = 10;
var result = x > y ? x : y;
Console.WriteLine(result);
Console.ReadLine();

}
So, in this way, we can say that by using ternary operator, we can achive syntactic sugar in our programming. Now, let's come to our main topic about Object Initialization and Collection Initialization.
So in programming, initialization is the assignment of an initial value for a data object or variable.

iii. Object Initializers:
Before going toward object initializers, let us see how we are initialising a object in C# 2.0:
public class Employee
{
public string Name { get; set; }
public int Id { get; set; }
public string Department { get; set; }
public int salary { get; set; }
}
class Program
{
static void Main(string[] args)
{
Employee emp=new Employee();
emp.Name = "Kumar";
emp.Department = "IT";
emp.Id = 101;
emp.salary = 80000;
Console.ReadLine();

}
}

Let's see how we can do that using object initializer in C# 3.0.

Write the same program using Object Initializer:
class Program
{
static void Main(string[] args)
{
Employee emp = new Employee {Name = "Kisan",Id = 55,Department = "IT",salary = 20000};

}
}
It seems that we have saved a lot of Key strokes using this Object Initializer. So, this is also considered as a "Syntactic Sugar".
iv. Collection Initializers:
Collection Initializers are used to initialize a collection in a planned and advance manner to avoid lot of Key strokes:
namespace syntax_sugar
{
public class Employee
{
public string Name { get; set; }
public int Id { get; set; }
public string Department { get; set; }
public int salary { get; set; }
}
class Program
{
static void Main(string[] args)
{

List liemp=new List();
Employee emp = new Employee();
emp.Name = "Kumar";
emp.Department = "IT";
emp.Id = 101;
emp.salary = 80000;
liemp.Add(emp); //one object is added in the list

Employee emp1 = new Employee();
emp1.Name = "Abdul";
emp1.Department = "IT";
emp1.Id = 1010;
emp1.salary = 80000;
liemp.Add(emp1); //Second object is added in the List

}
}

Let's see how we can improve our coading quality using collection Initializers. Consider the following program for reference:

static void Main(string[] args)
{

List liemp = new List
{
new Employee {Name = "Kumar",Id = 101,Department = "IT",salary = 80000},
new Employee {Name = "Abdul",Id = 1010,Department = "IT",salary = 80000}

};
}

Conclusion:

Here, our main intention is to make you aware about Collection Initialization and Object Initiallization which are two important concepts discovered in C# 3.0, and let you know how these two important concepts are considered as syntactic sugar in progromming.
Hope you liked this article. If you have any doubts  and suggestation, please do comment so that I can update.
read less
Comments
Dislike Bookmark

Asked on 07/08/2017 IT Courses/Microsoft Training/Microsoft Dynamics NAV .Net/C# .NET

Hi UrbanPro, I want to given training in Ms- dynamics Crm and C#.

Answer

Asked on 07/08/2017 .Net/C# .NET IT Courses/MS CRM

Hi Urban Pro, I want to give Training in online for C# .net and Ms Dynamics CRM. I have total 3 yrs of... read more
Hi Urban Pro, I want to give Training in online for C# .net and Ms Dynamics CRM. I have total 3 yrs of exp in both technologies, currently am working in Infosys. read less

Answer

Looking for C# .NET

Find best C# .NET in your locality on UrbanPro.

FIND NOW

Lesson Posted on 02/08/2017 .Net/C# .NET

What Is The Difference In For...Loop And Foreach Loop?

Neelam Sharma

I have a good experience in teaching in corporate sector, school, colleges ad institutes. I conduct training...

Loop is very important in C# Programing language. Loop is call iteration statement, loops are used for executing the repeated task. 1. For...Loop: The for…loop executes a statement or a block of statements repeatedly until a specified expression is false. For…loop contain the maximum... read more

Loop is very important in C# Programing language. Loop is call iteration statement, loops are used for executing the repeated task.

 1. For...Loop:

The for…loop executes a statement or a block of statements repeatedly until a specified expression is false. For…loop contain the maximum and minimum bound value.

For…loop Declaration:

For (initialization, Condition, increment/decrement)

{

}

 Initialization like int i = 0; //minimum bound

Condition like i < 5; //maximum bound

Example of for…loop:

For(int i=0;i<=5;i++){

Console.WriteLine(i);

}

Example of for…loop with array:

Int[] a=new int[5]{10,20,30,40,50};

For(int i=0;i<5;i++)

{

Console.WriteLine(a[i]);

}

The for…loop always start with integer value. Means initialization of for…loop is done with int.

2. Foreach loop:

The foreach loop is a group of embedded statements for each element in an array or an object collection. There is no need to specify the maximum and minimum bound value. In foreach loop we can assign integer, string, float, char any type of data.

Example:

Foreach loop declaration:

Foreach(datatype variable_name in collection_name)

{

}

Example 2:

Int[] x=new int[5]{3,4,5,6,7};

Foreach(int k in x)

{

Console.WriteLine(k);

}

Example 3 foreach loop with string:

String[] fruits=new string[5]{“Apple”,”Banana”,”Kiwi”,”Mango”,”BlueBerry”};

Foreach(string k in fruits)

{

Console.WriteLine(k);

}

Example 4: Foreach loop with float data:

Float[] data=new float[3]{3400.56f,2000.53f,7800.23f};

Foreach(float k in data)

{

Console.writeLine(k);

}

read less
Comments
Dislike Bookmark

Lesson Posted on 02/08/2017 .Net/C# .NET

What Is An Array? Explain Its Type.

Neelam Sharma

I have a good experience in teaching in corporate sector, school, colleges ad institutes. I conduct training...

Array: Array is a collection of similar type of data in an array varaiable. Array start with Zero Index and maximum length of array is total element - 1. i.e., Suppose n is the length of array, total element in array is n-1. In memory it occupy the contiguous memory locations. The lowest address is the... read more

Array: Array is a collection of similar type of data in an array varaiable. Array start with Zero Index and maximum length of array is total element - 1. i.e., Suppose n is the length of array, total element in array is n-1. In memory it occupy the contiguous memory locations. The lowest address is the first element of an array and highest is the last element of an array.

A[0]

A[1]

A[2]

A[3]

A[4]

A[5]

A[6]

A[7]

Declare an Array:

Int[] A =new int [8];

  1. Datatype is used to specify the type of an array.
  2. [] specifies the rank of an array or number of elements store in an array.
  3. Array_name specifies the name of an array.
  4. New keyword is used to allocate the memory block for an array.

Assigning value in an array:

Example 1:

Int[] A=new int[8];

A[0]=10;

A[1]=20;

Example 2:

Int[] A=new int[8]{10,20,30,40,50,60,70};

Here we declare and assign value in an array together.

Example 3:

String[] flowers=new string[]{“Lotus”,”Lilly”,”Rose”};

Here also assign value in an array but without specify the array size. In memory location it will take size of an array depend on the value we assign.

Types of Array

  1. Single Dimension array
  2. Multi Dimension Array
  3. Jagged Array

1. Single Dimension Array:

int[] x=new int[5];

string[] food=new string[]{“Pizza”,”Burger”,”Pasta”};

In single dimension there is only one dimension and start with 0 index.

2. Multi Dimension Array:

Multi Dimension array are 2-D array or 3-D array.

2-D array can be thought of a table or in matrix format.  Which has x as number of rows and y as number of columns. Example

Int[,] B=new int[2,3];

Here 2 means number of rows and 3 stands for number of columns.

B[0][0]

B[0][1]

B[0][2]

B[1][0]

B[1][1]

B[1][2]

Initialize an array of 2-D

Int[,] D=new int[3,3]{{1,2,3},{4,5,6},{7,8,9}};

1

2

3

4

5

6

7

8

9

3. Jagged Array:

Jagged Array is an array whose elements are array. It is call array within array. The dimension and size of jagged array is different in each element.

Declaration of jagged array:

Int[][] K=new int[2][];

In the above statement 2 is number of rows in a jagged array.

Initialize value in an array:

K[0]=new int[5];

K[1]=new int[2];

K[0]-is the first element of array and now size of this array is total element-1.

K[1]-is the 2nd row of an array and total element-1.

K[0][0]

K[0][1]

K[0][1]

K[0][2]

K[0][3]

K[1][0]

K[1][1]

K[1][2]

 

 

read less
Comments
Dislike Bookmark

Lesson Posted on 15/06/2017 IT Courses/SQL Programming IT Courses/MS SQL .Net +1 .Net/C# .NET less

Coding Instructions To Prevent SQL-Injection

Animesh

SQL-Injection is a very sensitive and very common technology to hack an application. I am describing a few techniques to make the SQL-Injection difficult. The main point of injection is a dynamic query. Whenever a dynamic query is executed on the database there is a chance of SQL-Injection. If we follow... read more

SQL-Injection is a very sensitive and very common technology to hack an application. I am describing a few techniques to make the SQL-Injection difficult.

The main point of injection is a dynamic query. Whenever a dynamic query is executed on the database there is a chance of SQL-Injection. If we follow some rule then we can minimize the hack attack.

Microsoft suggests using parameterized queries to avoid the SQL-Injection hack. For detailed information kindly visit: How To: Protect From SQL Injection in ASP.NET. We can create a parameterized query in both applications and databases. I am describing how to create and execute a parameterized query.

Generally we use this terminology to create and execute a query.

Code

In the preceding query if vulnerable data is passed using a query string “name” then the SQL-Injection can happen. Suppose a hacker passes “sumit’ or 1=1--” as the value of the query string “name” then the actual query that will be executed on the database will be:

code

This query will return all the records. In the same manner any query can be executed using this page or parameter. Like when a hacker passes “sumit’; drop table TestInjection;--” the actual query that will be executed will be:

code

To prevent these queries from execution we can create the same queries in this way.

corrected code

If queries are created in the preceding form then the @name parameter is treated as a literal value and not as executable code. In other words if any injection values are passed using a parameter then whatever is passed in the parameter will be entirely used as a single value, not as two separate queries. And as a result no result will be returned from the database.

Sometimes we need to create and execute dynamic queries in a procedure also. Normally we create dynamic queries in this way.

corrected code

This way of creating and executing a query is again vulnerable. For testing just create the procedure as shown above and execute in the following manner.

We can create parameterized queries in a database too. See the following code:

I would like to describe the method of creating and executing a query. I will describe only the preceding query. For detailed information please refer to the following online documentation: sp_executesql (Transact-SQL) and Using sp_executesql.

For creating a dynamic query in SQL server first declare a nvarchar variable and assign a query to this variable. In the query text write SQL parameters instead of the actual parameter passed to the procedure from the application as I used @namenew.

Now again declare a new nvarchar variable for parameter definition. This variable will describe the parameter details that are used in the actual query. As I declared @p.

Now use the sp_executesql procedure to execute this query. This procedure will take three arguments to execute the query. First the query to be executed, second the parameter defining the variable and third the value for the parameters used in the query.

If any query is written and executed in this way then it is safe from SQL-Injection.

read less
Comments
Dislike Bookmark

Looking for C# .NET

Find best C# .NET in your locality on UrbanPro.

FIND NOW

Lesson Posted on 14/05/2017 .Net/C# .NET

Understanding Delegate in C# .NET

P K Subudhi

I have 12 years of teaching experience. Before that I was System Analyst Programmer. Since 2004 I taught...

C# Delegate technique Delegate is one of the fantastic tool & technique in C#.NET. Using deleagte technique the following benefits could be avaialed One can define a method without name (Anonymous Method) One can pass a Method as argument to another Method Can join (or Add) two or more non-returnable... read more

C# Delegate technique

Delegate is one of the fantastic tool & technique in C#.NET. Using deleagte technique the following benefits could be avaialed

  • One can define a method without name (Anonymous Method)
  • One can pass a Method as argument to another Method
  • Can join (or Add) two or more non-returnable methods methods
  • Core to combine event and event actions

Here is a simple example that demonstrates how delegates are being used in C#

Delegate used with instance method, static method, general named method and Anonymous method

Delegate Example

 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

public delegate int DelType(int n);

namespace DelDemo

{

    class Num

    {

        int a;

        public Num() { a = 0; }

        public Num(int n) { a = n; }

        public void Disp() { Console.WriteLine("Data is " + a); }

        public int Power(int n) // Instance method

        {

            int r = 1;

            while ( n> 0)

            {

                r = r * a;

                n--;

            }

            return r;

        }

        static public int Rev(int t) // Static method

        {

            int r = 0;

          

            while (t > 0)

            {

                r = (r * 10) + (t % 10);

                t = t / 10;

            }

            return r;

        }

    }

    class Program

    {

        static int Fact(int n) // Named method

        {

            int f=1;

            while(n>1)f*=n--;

            return f;

        }

        static void Main(string[] args)

        {

            DelType act = delegate(int n)  //Anonymous method

            {

                int s = 0;

                while (n > 0)

                {

                    s = s + (n % 10);

                    n = n / 10;

                }

                return s;

            };

            Console.WriteLine("Sum of digit is "+act(234));

            Num p = new Num(5);

            act = Num.Rev;    // Using static method

            Console.WriteLine("Reverse number is " + act(567));

            act = Fact; // Using general named method

            Console.WriteLine("Factorial is " + act(5));

            act = p.Power; //Using instance method

            Console.WriteLine("Power is " + act(3));

            Console.ReadKey();

        }

    }

}

 

read less
Comments
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best C# .NET in India. Post Your Requirement today and get connected.

Overview

Lessons 21

Total Shares  

+ Follow 20,933 Followers

Top Contributors

Connect with Expert Tutors & Institutes for C# .NET

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more