C Sharp Constructor

C# Constructor A constructor in C# is invoked automatically at the time of object creation. It is a special method having the same name as class or struct and is generally used to initialize the data members of a new object. The constructor in C# has the same name as class or struct. A constructor … Read more

Categories C#

C Sharp Object and Class

C# Object and Class Program in C# uses objects and classes as it is an object-oriented programming language. C# Object: An entity with a state and behavior can be called as an Object. In terms of an object-oriented programming language, the state of an object implies data and the term behavior implies functionality. An object … Read more

Categories C#

Command Line Arguments

C# Command Line Arguments When an argument is passed by the command line, then it is called as a command-line argument. The arguments are passed to the Main method during the execution of the code. The values to be passed from the command line, are specified in the string args variable. Example: using System; namespace … Read more

Categories C#

C Sharp Array class

C# Array class To work with the various array related operations, an Array class is facilitated by C#. For creating, manipulating, searching, and sorting elements of an array, the Array class in C# provides several methods and properties. For all arrays in the .NET programming environment, the C# class works as the base class. Being … Read more

Categories C#

C Sharp Params

C# Params To specify a parameter to take a variable number of arguments, especially when the number of arguments is not priorly known, the params keyword is used in C#. In C#, only one params keyword is allowed in a function declaration. After the params keyword, no other parameter is permitted. Example 1: using System; … Read more

Categories C#

C Sharp Jagged Arrays

C# Jagged Arrays The elements of a jagged array in C# are arrays, and hence it is also called “array of arrays”. In a jagged array, the size of the elements can be different. Declaration of Jagged array: In the below example, we are declaring a jagged array with two elements. int[][] a = new … Read more

Categories C#

C Sharp Multidimensional Arrays

C# Multidimensional Arrays Also known as rectangular arrays, a multi-dimensional array in C# can be either a two-dimensional array or a three-dimensional array. The data in a multi-dimensional array is stored in a tabular form, i.e, in the form of row * column, thus forming a matrix of elements. The comma is used inside the … Read more

Categories C#

C Sharp Passing Array to Function

C# Passing Array to Function We can create a function in C#, to reuse the logic of an array. Only the array name is needed to pass an array to function in C#. Syntax: function_name(array_name); Example 1: Printing array elements. using System; public class Example { static void display(int[] a) { Console.WriteLine("Array elements:"); for (int … Read more

Categories C#

C Sharp Arrays

C# Arrays A group of similar types of elements with a contiguous memory location is called an Array in C#. An array in C# is similar to those in other programming languages like C and C++. Being an object of base type System.Array, array in C# can only store a fixed set of elements and … Read more

Categories C#

C Sharp Out Parameter

C# Out Parameter To pass arguments as out-type, the out keyword is used in C#. Variable is not required in the out-type to initialize before passing. But other than that it is similar to the reference-type. It is mostly used to pass an argument as out-type and for a function to return multiple values. Example … Read more

Categories C#